Advertisement
Pteridium

Board roamer kernel 2.6

Feb 23rd, 2015
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 108.10 KB | None | 0 0
  1. /*
  2.  * Copyright (C) 2007 Google, Inc.
  3.  * Copyright (c) 2008-2010, Code Aurora Forum. All rights reserved.
  4.  * Author: Brian Swetland <swetland@google.com>
  5.  *
  6.  * This software is licensed under the terms of the GNU General Public
  7.  * License version 2, as published by the Free Software Foundation, and
  8.  * may be copied, distributed, and modified under those terms.
  9.  *
  10.  * This program is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  * GNU General Public License for more details.
  14.  *
  15.  */
  16.  
  17. /* ========================================================================================
  18. when         who        what, where, why                             comment tag
  19. ---------     -------       -------------------------------------------------------     --------------------------
  20.  
  21. ==========================================================================================*/
  22. #include <linux/kernel.h>
  23. #include <linux/init.h>
  24. #include <linux/platform_device.h>
  25. #include <linux/input.h>
  26. #include <linux/io.h>
  27. #include <linux/delay.h>
  28. #include <linux/bootmem.h>
  29. //#include <linux/usb/mass_storage_function.h>
  30. #include <linux/power_supply.h>
  31.  
  32.  
  33. #include <mach/hardware.h>
  34. #include <asm/mach-types.h>
  35. #include <asm/mach/arch.h>
  36. #include <asm/mach/map.h>
  37. #include <asm/mach/flash.h>
  38. #include <asm/setup.h>
  39. #ifdef CONFIG_CACHE_L2X0
  40. #include <asm/hardware/cache-l2x0.h>
  41. #endif
  42.  
  43. #include <asm/mach/mmc.h>
  44. #include <mach/vreg.h>
  45. #include <mach/mpp.h>
  46. #include <mach/gpio.h>
  47. #include <mach/board.h>
  48. #include <mach/msm_iomap.h>
  49. #include <mach/msm_rpcrouter.h>
  50. #include <mach/msm_hsusb.h>
  51. #include <mach/rpc_hsusb.h>
  52. #include <mach/rpc_pmapp.h>
  53. #include <mach/msm_serial_hs.h>
  54. #include <mach/memory.h>
  55. #include <mach/msm_battery.h>
  56. #include <mach/rpc_server_handset.h>
  57.  
  58.  
  59. #include <linux/mtd/nand.h>
  60. #include <linux/mtd/partitions.h>
  61. #include <linux/i2c.h>
  62. #include <linux/i2c-gpio.h>
  63. #include <linux/android_pmem.h>
  64. #include <mach/camera.h>
  65. #include <linux/proc_fs.h>
  66. #include <mach/zte_memlog.h>
  67. #include "devices.h"
  68. #include "socinfo.h"
  69. #include "clock.h"
  70. #include "msm-keypad-devices.h"
  71. #ifdef CONFIG_USB_ANDROID
  72. #include <linux/usb/android_composite.h>
  73. #endif
  74. #include "pm.h"
  75. #ifdef CONFIG_ARCH_MSM7X27
  76. #include <linux/msm_kgsl.h>
  77. #endif
  78.  
  79. #ifdef CONFIG_ZTE_PLATFORM
  80. //#include "msm_usb_config.h" //USB-HML-001
  81. #endif
  82. #include <linux/lis302dl.h>
  83. #if defined( CONFIG_TOUCHSCREEN_MSM_LEGACY)
  84. #include <mach/msm_touch.h>
  85. #elif defined( CONFIG_TOUCHSCREEN_MSM)
  86. #include <mach/msm_ts.h>
  87. #endif
  88. #ifdef CONFIG_TOUCHSCREEN_SYNAPTICS_3K
  89. #include <linux/input/synaptics_i2c_rmi.h>
  90. #endif
  91. /*ZTE_TS_ZFJ_20110509 begin*/
  92. #ifdef CONFIG_TOUCHSCREEN_MXT224
  93. #include <linux/atmel_qt602240.h>
  94. extern struct atmel_i2c_platform_data atmel_data;
  95. #endif
  96.  
  97. //ZTE_TS_XYM_20110715 begin
  98. #ifdef CONFIG_TOUCHSCREEN_CY8CTST241
  99. #include <linux/cyttsp.h>
  100.  
  101. #define CY_USE_MT       /* define if using Single-Touch */
  102. //#define CY_USE_SPI        /* define if using SPI interface */
  103. #define CY_USE_I2C      /* define if using I2C interface  */
  104.  
  105. #ifdef CY_USE_SPI
  106. #define CY_SPI_IRQ_GPIO 139 /* xxx board GPIO */
  107. /* optional init function; set up IRQ GPIO;
  108.  * call reference in platform data structure
  109.  */
  110. static int cyttsp_spi_init(int on)
  111. {
  112.     int ret;
  113.  
  114.  
  115.     /* add any special code to initialize any required system hw
  116.      * such as regulators or gpio pins
  117.      */
  118.  
  119.  
  120.     if (on) {
  121.         gpio_direction_input(CY_SPI_IRQ_GPIO);
  122.         /* for MSM systems the call to gpio_direction_input can be
  123.          * replaced with the more explicit call:
  124.          gpio_tlmm_config(GPIO_CFG(CY_SPI_IRQ_GPIO, 0, GPIO_INPUT,
  125.             GPIO_PULL_UP, GPIO_6MA), GPIO_ENABLE);
  126.          */
  127.         ret = gpio_request(CY_SPI_IRQ_GPIO, "CYTTSP IRQ GPIO");
  128.         if (ret) {
  129.             printk(KERN_ERR "%s: Failed to request GPIO %d\n",
  130.                    __func__, CY_SPI_IRQ_GPIO);
  131.             return ret;
  132.         }
  133.     } else {
  134.         gpio_free(CY_SPI_IRQ_GPIO);
  135.     }
  136.     return 0;
  137. }
  138.  
  139. static int cyttsp_spi_wakeup(void)
  140. {
  141.     return 0;
  142. }
  143.  
  144. static struct cyttsp_platform_data cypress_spi_ttsp_platform_data = {
  145.     .wakeup = cyttsp_spi_wakeup,
  146.     .init = cyttsp_spi_init,
  147. #ifdef CY_USE_MT
  148.     .mt_sync = input_mt_sync,
  149. #endif
  150.     .maxx = 240,
  151.     .maxy = 320,
  152.     .flags = 0,
  153.     .gen = CY_GEN3,
  154.     .use_st = 0,
  155.     .use_mt = 1,
  156.     .use_trk_id = 0,
  157.     .use_hndshk = 1,
  158.     .use_timer = 0,
  159.     .use_sleep = 1,
  160.     .use_gestures = 0,
  161.     .use_load_file = 1,
  162.     .use_force_fw_update = 1,
  163.     .use_virtual_keys = 0,
  164.     /* activate up to 4 groups
  165.      * and set active distance
  166.      */
  167.     .gest_set = CY_GEST_GRP_NONE | CY_ACT_DIST,
  168.     /* change act_intrvl to customize the Active power state
  169.      * scanning/processing refresh interval for Operating mode
  170.      */
  171.     .act_intrvl = CY_ACT_INTRVL_DFLT,
  172.     /* change tch_tmout to customize the touch timeout for the
  173.      * Active power state for Operating mode
  174.      */
  175.     .tch_tmout = CY_TCH_TMOUT_DFLT,
  176.     /* change lp_intrvl to customize the Low Power power state
  177.      * scanning/processing refresh interval for Operating mode
  178.      */
  179.     .lp_intrvl = CY_LP_INTRVL_DFLT,
  180.     .name = CY_SPI_NAME,
  181.     .irq_gpio = CY_SPI_IRQ_GPIO,
  182. };
  183.  
  184. static struct spi_board_info xxx_cyttsp_spi_board_info[] __initdata = {
  185.     {
  186.         .modalias = CY_SPI_NAME,
  187.         .platform_data  = &cypress_spi_ttsp_platform_data,
  188.         .irq = INT_34XX_SPI4_IRQ,
  189.         .max_speed_hz   = 1000000,
  190.         .bus_num = 4,
  191.         .chip_select = 0,
  192.         .mode = SPI_MODE_0,
  193.     },
  194. };
  195.  
  196. static void __init xxx_spi_cyttsp_init(void)
  197. {
  198.     printk(KERN_INFO "irq = %d\n",
  199.         xxx_cyttsp_spi_board_info[0].irq);
  200.     spi_register_board_info(xxx_cyttsp_spi_board_info,
  201.         ARRAY_SIZE(xxx_cyttsp_spi_board_info));
  202. }
  203. #endif /* CY_USE_SPI */
  204.  
  205. #ifdef CY_USE_I2C
  206. #define CY_I2C_IRQ_GPIO 29  /* xxx board GPIO */
  207.  
  208. /* optional init function; set up IRQ GPIO;
  209.  * call reference in platform data structure
  210.  */
  211. static int cyttsp_i2c_init(int on)
  212. {
  213.     int ret;
  214.  
  215.  
  216.     /* add any special code to initialize any required system hw
  217.      * such as regulators or gpio pins
  218.      */
  219.  
  220.  
  221.     if (on) {
  222.         gpio_direction_input(CY_I2C_IRQ_GPIO);
  223.         /* for MSM systems the call to gpio_direction_input can be
  224.          * replaced with the more explicit call:
  225.          gpio_tlmm_config(GPIO_CFG(CY_I2C_IRQ_GPIO, 0, GPIO_INPUT,
  226.             GPIO_PULL_UP, GPIO_6MA), GPIO_ENABLE);
  227.          */
  228.         ret = gpio_request(CY_I2C_IRQ_GPIO, "CYTTSP IRQ GPIO");
  229.         if (ret) {
  230.             printk(KERN_ERR "%s: Failed to request GPIO %d\n",
  231.                    __func__, CY_I2C_IRQ_GPIO);
  232.             return ret;
  233.         }
  234.     } else {
  235.         gpio_free(CY_I2C_IRQ_GPIO);
  236.     }
  237.     return 0;
  238. }
  239.  
  240. static int cyttsp_i2c_wakeup(void)
  241. {
  242.         gpio_direction_output(CY_I2C_IRQ_GPIO, 1);
  243.     usleep(10);
  244.     gpio_set_value(CY_I2C_IRQ_GPIO,0);
  245.     usleep(10);
  246.     gpio_set_value(CY_I2C_IRQ_GPIO,1);
  247.     usleep(10);
  248.     gpio_set_value(CY_I2C_IRQ_GPIO,0);
  249.     usleep(10);
  250.     gpio_set_value(CY_I2C_IRQ_GPIO,1);
  251.    
  252.     usleep(10);
  253.     gpio_direction_input(CY_I2C_IRQ_GPIO);
  254.  
  255.     return 0;
  256. }
  257.  
  258. static struct cyttsp_platform_data cypress_i2c_ttsp_platform_data = {
  259.     .wakeup = cyttsp_i2c_wakeup,
  260.     //.wakeup = NULL,
  261.     .init = cyttsp_i2c_init,
  262. #ifdef CY_USE_MT
  263.     .mt_sync = input_mt_sync,
  264. #endif
  265.     .maxx = 320,
  266.     .maxy = 480,
  267.     .flags = 0,
  268.     .gen = CY_GEN2,
  269.     .use_st = 0,
  270.     .use_mt = 1,
  271.     .use_trk_id = 0,
  272.     .use_hndshk = 1,
  273.     .use_timer = 0,
  274.     .use_sleep = 1,
  275.     .use_gestures = 0,
  276.     .use_load_file = 0,
  277.     .use_force_fw_update = 0,
  278.     .use_virtual_keys = 0,
  279.     /* activate up to 4 groups
  280.      * and set active distance
  281.      */
  282.     .gest_set = CY_GEST_GRP_NONE | CY_ACT_DIST,
  283.     /* change act_intrvl to customize the Active power state
  284.      * scanning/processing refresh interval for Operating mode
  285.      */
  286.     .act_intrvl = CY_ACT_INTRVL_DFLT,
  287.     /* change tch_tmout to customize the touch timeout for the
  288.      * Active power state for Operating mode
  289.      */
  290.     .tch_tmout = CY_TCH_TMOUT_DFLT,
  291.     /* change lp_intrvl to customize the Low Power power state
  292.      * scanning/processing refresh interval for Operating mode
  293.      */
  294.     .lp_intrvl = CY_LP_INTRVL_DFLT,
  295.     .name = CY_I2C_NAME,
  296.     .irq_gpio = CY_I2C_IRQ_GPIO,
  297. };
  298.  
  299.  
  300. #endif /* CY_USE_I2C */
  301. #endif // CONFIG_TOUCHSCREEN_CY8CTST241
  302. //ZTE_TS_XYM_20110715 end
  303.  
  304. #ifdef CONFIG_ARCH_MSM7X25
  305. #define MSM_PMEM_MDP_SIZE   0xb21000
  306. #define MSM_PMEM_ADSP_SIZE  0x97b000
  307. #define MSM_PMEM_AUDIO_SIZE 0x121000
  308. #define MSM_FB_SIZE     0x200000
  309. #define PMEM_KERNEL_EBI1_SIZE   0x64000
  310. #endif
  311.  
  312. #ifdef CONFIG_ARCH_MSM7X27
  313. #define MSM_PMEM_MDP_SIZE   0x1B76000
  314. #define MSM_PMEM_ADSP_SIZE  0xB71000
  315. #define MSM_PMEM_AUDIO_SIZE 0x5B000
  316. #define MSM_FB_SIZE     0x177000
  317. #define MSM_GPU_PHYS_SIZE   SZ_2M
  318. #define PMEM_KERNEL_EBI1_SIZE   0x1C000
  319. /* Using lower 1MB of OEMSBL memory for GPU_PHYS */
  320. #define MSM_GPU_PHYS_START_ADDR  0xD600000ul
  321. #endif
  322.  
  323. #ifdef CONFIG_ANDROID_RAM_CONSOLE
  324. #define MSM_RAM_CONSOLE_PHYS  0x02500000 //ZTE_BOOT_HUANGYANJUN_20100903_01
  325. #define MSM_RAM_CONSOLE_SIZE  SZ_1M
  326. #endif
  327.  
  328. static smem_global *global;
  329.  
  330. //ZTE_BOOT_JIANGFENG_20100223_01, start
  331. #ifdef CONFIG_ZTE_PLATFORM
  332. static int g_zte_ftm_flag_fixup;
  333. static int lcd_first_reset = false;//ZTE_DRIVE_LCD_LKEJ_20110620
  334. #endif
  335. //ZTE_BOOT_JIANGFENG_20100223_01, end
  336.  
  337. /* Using upper 1/2MB of Apps Bootloader memory*/
  338. #define MSM_PMEM_AUDIO_START_ADDR   0x80000ul
  339.  
  340. static struct resource smc91x_resources[] = {
  341.     [0] = {
  342.         .start  = 0x9C004300,
  343.         .end    = 0x9C0043ff,
  344.         .flags  = IORESOURCE_MEM,
  345.     },
  346.     [1] = {
  347.         .start  = MSM_GPIO_TO_INT(132),
  348.         .end    = MSM_GPIO_TO_INT(132),
  349.         .flags  = IORESOURCE_IRQ,
  350.     },
  351. };
  352.  
  353. #ifdef CONFIG_USB_FUNCTION
  354. #ifndef CONFIG_ZTE_PLATFORM
  355. static struct usb_mass_storage_platform_data usb_mass_storage_pdata = {
  356.     .nluns          = 0x02,
  357.     .buf_size       = 16384,
  358.     .vendor         = "GOOGLE",
  359.     .product        = "Mass storage",
  360.     .release        = 0xffff,
  361. };
  362. #endif
  363.  
  364. static struct platform_device mass_storage_device = {
  365.     .name           = "usb_mass_storage",
  366.     .id             = -1,
  367.     .dev            = {
  368.         .platform_data          = &usb_mass_storage_pdata,
  369.     },
  370. };
  371. #endif
  372.  
  373. #if 0
  374. #ifdef CONFIG_USB_ANDROID
  375. //ruanmeisi 20100713 zte pid
  376. #define PRODUCT_ID_ALL_INTERFACE          0x1350
  377. #define PRODUCT_ID_MS_ADB                      0x1351
  378. #define PRODUCT_ID_ADB                             0x1352
  379. #define PRODUCT_ID_MS                               0x1353
  380. #define PRODUCT_ID_DIAG                           0x0112
  381. #define PRODUCT_ID_DIAG_NMEA_MODEM   0x0111
  382. #define PRODUCT_ID_MODEM_MS_ADB         0x1354
  383. #define PRODUCT_ID_MODEM_MS                 0x1355
  384. #define PRODUCT_ID_MS_CDROM                 0x0083
  385. #define PRODUCT_ID_RNDIS_MS                 0x1364
  386. #define PRODUCT_ID_RNDIS_MS_ADB             0x1364
  387. #define PRODUCT_ID_RNDIS             0x1365
  388. /*ZTE_USB_WZY_101021 start*/
  389. #define PRODUCT_ID_DIAG_MODEM_NEMA_MS_AT             0x1367
  390. #define PRODUCT_ID_DIAG_MODEM_NEMA_MS_ADB_AT             0x1366
  391. #define PRODUCT_ID_RNDIS_ADB             0x1373
  392. /* dynamic composition */
  393. static struct usb_composition usb_func_composition[] = {
  394. #ifdef  CONFIG_ZTE_PLATFORM
  395.     {
  396.         /* MSC */
  397.         .product_id         = PRODUCT_ID_MS,
  398.         .functions      = 0x02,
  399.         .adb_product_id     = PRODUCT_ID_MS_ADB,
  400.         .adb_functions      = 0x12
  401.     },
  402.     {
  403.         /* ADB*/
  404.         .product_id         = PRODUCT_ID_ADB,  /*ZTE_USB_WZY_101021*/
  405.         .functions      = 0x01,
  406.         .adb_product_id     = PRODUCT_ID_ADB,
  407.         .adb_functions      = 0x01
  408.     },
  409.     {
  410.         /* diag + modem + nmea + ms + adb*/
  411.         .product_id         = PRODUCT_ID_ALL_INTERFACE,
  412.         .functions      = 0x12764,
  413.         .adb_product_id     = PRODUCT_ID_ALL_INTERFACE,
  414.         .adb_functions      = 0x12764
  415.     },
  416.     {
  417.         /* diag + nmea + modem */
  418.         .product_id         = PRODUCT_ID_DIAG_NMEA_MODEM,
  419.         .functions      = 0x674,
  420.         .adb_product_id     = PRODUCT_ID_DIAG_NMEA_MODEM,
  421.         .adb_functions      = 0x674
  422.     },
  423.     {
  424.         /* diag */
  425.         .product_id         = PRODUCT_ID_DIAG,
  426.         .functions      = 0x4,
  427.         .adb_product_id     = PRODUCT_ID_DIAG,
  428.         .adb_functions      = 0x4
  429.     },
  430.     {
  431.         /* modem + ms + adb */
  432.         .product_id         = PRODUCT_ID_MODEM_MS,
  433.         .functions      = 0x26,
  434.         .adb_product_id     = PRODUCT_ID_MODEM_MS_ADB,
  435.         .adb_functions      = 0x126
  436.     },
  437.     {
  438.         /* ms + CDROM */
  439.         .product_id         = PRODUCT_ID_MS_CDROM,
  440.         .functions      = 0x2,
  441.         .adb_product_id     = PRODUCT_ID_MS_CDROM,
  442.         .adb_functions      = 0x2
  443.     },
  444.     {
  445.         /* rndis + ms + adb */
  446.         .product_id         = PRODUCT_ID_RNDIS_MS,
  447.         .functions      = 0x2A,
  448.         .adb_product_id     = PRODUCT_ID_RNDIS_MS_ADB,
  449.         .adb_functions      = 0x12A
  450.     },
  451.     {
  452.         /* rndis */
  453.         .product_id         = PRODUCT_ID_RNDIS,
  454.         .functions      = 0xA,
  455.         .adb_product_id     = PRODUCT_ID_RNDIS,
  456.         .adb_functions      = 0xA
  457.     },
  458.     {
  459.         /* rndis + adb*/
  460.         .product_id         = PRODUCT_ID_RNDIS_ADB,
  461.         .functions      = 0xA,
  462.         .adb_product_id     = PRODUCT_ID_RNDIS_ADB,
  463.         .adb_functions      = 0x1A
  464.     },
  465.     /*ZTE_USB_WZY_101021 start*/
  466.     {
  467.         /* diag+modm+nema+ms+at*/
  468.         .product_id         = PRODUCT_ID_DIAG_MODEM_NEMA_MS_AT,
  469.         .functions      = 0xB2764,
  470.         .adb_product_id     = PRODUCT_ID_DIAG_MODEM_NEMA_MS_ADB_AT,
  471.         .adb_functions      = 0xB12764
  472.     },
  473.     {
  474.         /* diag+modm+nema+ms+adb+at*/
  475.         .product_id         = PRODUCT_ID_DIAG_MODEM_NEMA_MS_ADB_AT,
  476.         .functions      = 0xB12764,
  477.         .adb_product_id     = PRODUCT_ID_DIAG_MODEM_NEMA_MS_ADB_AT,
  478.         .adb_functions      = 0xB12764
  479.     },/*ZTE_USB_WZY_101021 end*/
  480.  
  481. #else
  482.     {
  483.         /* MSC */
  484.         .product_id         = 0xF000,
  485.         .functions      = 0x02,
  486.         .adb_product_id     = 0x9015,
  487.         .adb_functions      = 0x12
  488.     },
  489. #ifdef CONFIG_USB_F_SERIAL
  490.     {
  491.         /* MODEM */
  492.         .product_id         = 0xF00B,
  493.         .functions      = 0x06,
  494.         .adb_product_id     = 0x901E,
  495.         .adb_functions      = 0x16,
  496.     },
  497. #endif
  498. #ifdef CONFIG_USB_ANDROID_DIAG
  499.     {
  500.         /* DIAG */
  501.         .product_id         = 0x900E,
  502.         .functions      = 0x04,
  503.         .adb_product_id     = 0x901D,
  504.         .adb_functions      = 0x14,
  505.     },
  506. #endif
  507. #if defined(CONFIG_USB_ANDROID_DIAG) && defined(CONFIG_USB_F_SERIAL)
  508.     {
  509.         /* DIAG + MODEM */
  510.         .product_id         = 0x9004,
  511.         .functions      = 0x64,
  512.         .adb_product_id     = 0x901F,
  513.         .adb_functions      = 0x0614,
  514.     },
  515.     {
  516.         /* DIAG + MODEM + NMEA*/
  517.         .product_id         = 0x9016,
  518.         .functions      = 0x764,
  519.         .adb_product_id     = 0x9020,
  520.         .adb_functions      = 0x7614,
  521.     },
  522.     {
  523.         /* DIAG + MODEM + NMEA + MSC */
  524.         .product_id         = 0x9017,
  525.         .functions      = 0x2764,
  526.         .adb_product_id     = 0x9018,
  527.         .adb_functions      = 0x27614,
  528.     },
  529. #endif
  530. #ifdef CONFIG_USB_ANDROID_CDC_ECM
  531.     {
  532.         /* MSC + CDC-ECM */
  533.         .product_id         = 0x9014,
  534.         .functions      = 0x82,
  535.         .adb_product_id     = 0x9023,
  536.         .adb_functions      = 0x812,
  537.     },
  538. #endif
  539. #ifdef CONFIG_USB_ANDROID_RMNET
  540.     {
  541.         /* DIAG + RMNET */
  542.         .product_id         = 0x9021,
  543.         .functions      = 0x94,
  544.         .adb_product_id     = 0x9022,
  545.         .adb_functions      = 0x914,
  546.     },
  547. #endif
  548. #ifdef CONFIG_USB_ANDROID_RNDIS
  549.     {
  550.         /* RNDIS */
  551.         .product_id         = 0xF00E,
  552.         .functions      = 0xA,
  553.         .adb_product_id     = 0x9024,
  554.         .adb_functions      = 0x1A,
  555.     },
  556. #endif
  557. #endif
  558. };
  559. static struct android_usb_platform_data android_usb_pdata = {
  560. #ifdef CONFIG_ZTE_PLATFORM
  561.     .vendor_id  = 0x19d2,
  562.     .version    = 0x0100,
  563.     .compositions   = usb_func_composition,
  564.     .num_compositions = ARRAY_SIZE(usb_func_composition),
  565.     .product_name   = "ZTE HSUSB Device",
  566.     .manufacturer_name = "ZTE Incorporated",
  567.     .nluns = 1,
  568.     #else
  569.     .vendor_id  = 0x05C6,
  570.     .version    = 0x0100,
  571.     .compositions   = usb_func_composition,
  572.     .num_compositions = ARRAY_SIZE(usb_func_composition),
  573.     .product_name   = "Qualcomm HSUSB Device",
  574.     .manufacturer_name = "Qualcomm Incorporated",
  575.     .nluns = 1,
  576.     #endif
  577. };
  578. static struct platform_device android_usb_device = {
  579.     .name   = "android_usb",
  580.     .id     = -1,
  581.     .dev        = {
  582.         .platform_data = &android_usb_pdata,
  583.     },
  584. };
  585. #endif
  586. static struct platform_device smc91x_device = {
  587.     .name       = "smc91x",
  588.     .id     = 0,
  589.     .num_resources  = ARRAY_SIZE(smc91x_resources),
  590.     .resource   = smc91x_resources,
  591. };
  592.  
  593.  
  594. #ifndef CONFIG_ZTE_PLATFORM
  595. #ifdef CONFIG_USB_FUNCTION
  596. static struct usb_function_map usb_functions_map[] = {
  597.     {"diag", 0},
  598.     {"adb", 1},
  599.     {"modem", 2},
  600.     {"nmea", 3},
  601.     {"mass_storage", 4},
  602.     {"ethernet", 5},
  603.     {"rmnet", 6},
  604. };
  605.  
  606. /* dynamic composition */
  607. static struct usb_composition usb_func_composition[] = {
  608.     {
  609.         .product_id         = 0x9012,
  610.         .functions      = 0x5, /* 0101 */
  611.     },
  612.  
  613.     {
  614.         .product_id         = 0x9013,
  615.         .functions      = 0x15, /* 10101 */
  616.     },
  617.  
  618.     {
  619.         .product_id         = 0x9014,
  620.         .functions      = 0x30, /* 110000 */
  621.     },
  622.  
  623.     {
  624.         .product_id         = 0x9016,
  625.         .functions      = 0xD, /* 01101 */
  626.     },
  627.  
  628.     {
  629.         .product_id         = 0x9017,
  630.         .functions      = 0x1D, /* 11101 */
  631.     },
  632.  
  633.     {
  634.         .product_id         = 0xF000,
  635.         .functions      = 0x10, /* 10000 */
  636.     },
  637.  
  638.     {
  639.         .product_id         = 0xF009,
  640.         .functions      = 0x20, /* 100000 */
  641.     },
  642.  
  643.     {
  644.         .product_id         = 0x9018,
  645.         .functions      = 0x1F, /* 011111 */
  646.     },
  647. #ifdef CONFIG_USB_FUNCTION_RMNET
  648.     {
  649.         .product_id         = 0x9021,
  650.         /* DIAG + RMNET */
  651.         .functions      = 0x41,
  652.     },
  653.     {
  654.         .product_id         = 0x9022,
  655.         /* DIAG + ADB + RMNET */
  656.         .functions      = 0x43,
  657.     },
  658. #endif
  659.  
  660. };
  661.  
  662. static struct msm_hsusb_platform_data msm_hsusb_pdata = {
  663.     .version    = 0x0100,
  664.     .phy_info   = (USB_PHY_INTEGRATED | USB_PHY_MODEL_65NM),
  665.     .vendor_id          = 0x5c6,
  666.     .product_name       = "Qualcomm HSUSB Device",
  667.     .serial_number      = "1234567890ABCDEF",
  668.     .manufacturer_name  = "Qualcomm Incorporated",
  669.     .compositions   = usb_func_composition,
  670.     .num_compositions = ARRAY_SIZE(usb_func_composition),
  671.     .function_map   = usb_functions_map,
  672.     .num_functions  = ARRAY_SIZE(usb_functions_map),
  673.     .config_gpio    = NULL,
  674. };
  675. #endif
  676.  
  677. #endif
  678. #endif
  679.  
  680. static struct platform_device smc91x_device = {
  681.     .name       = "smc91x",
  682.     .id     = 0,
  683.     .num_resources  = ARRAY_SIZE(smc91x_resources),
  684.     .resource   = smc91x_resources,
  685. };
  686.  
  687. #ifdef CONFIG_USB_ANDROID
  688. #if 0
  689. static char *usb_functions_default[] = {
  690.     "diag",
  691.     "modem",
  692.     "nmea",
  693.     "rmnet",
  694.     "usb_mass_storage",
  695. };
  696.  
  697. static char *usb_functions_default_adb[] = {
  698.     "diag",
  699.     "adb",
  700.     "modem",
  701.     "nmea",
  702.     "rmnet",
  703.     "usb_mass_storage",
  704. };
  705.  
  706. static char *usb_functions_rndis_diag[] = {
  707.     "rndis",
  708.     "diag",
  709. };
  710.  
  711. static char *usb_functions_rndis_adb_diag[] = {
  712.     "rndis",
  713.     "adb",
  714.     "diag",
  715. };
  716. #endif
  717.  
  718. static char *usb_functions_all[] = {
  719. #ifdef CONFIG_USB_ANDROID_RNDIS
  720.     "rndis",
  721. #endif
  722. #ifdef CONFIG_USB_ANDROID_DIAG
  723.     "diag",
  724. #endif
  725.     "adb",
  726. #ifdef CONFIG_USB_F_SERIAL
  727.     "modem",
  728.     "nmea",
  729. #endif
  730. #ifdef CONFIG_USB_ANDROID_RMNET
  731.     "rmnet",
  732. #endif
  733.     "usb_mass_storage",
  734. #ifdef CONFIG_USB_ANDROID_ACM
  735.     "acm",
  736. #endif
  737. #ifdef CONFIG_USB_ANDROID_AT
  738.     "at"
  739. #endif
  740. };
  741.  
  742.  
  743. #if 0
  744. static struct android_usb_product usb_products[] = {
  745.     {
  746.         .product_id = 0x9026,
  747.         .num_functions  = ARRAY_SIZE(usb_functions_default),
  748.         .functions  = usb_functions_default,
  749.     },
  750.     {
  751.         .product_id = 0x9025,
  752.         .num_functions  = ARRAY_SIZE(usb_functions_default_adb),
  753.         .functions  = usb_functions_default_adb,
  754.     },
  755.     {
  756.         .product_id = 0x902C,
  757.         .num_functions  = ARRAY_SIZE(usb_functions_rndis_diag),
  758.         .functions  = usb_functions_rndis_diag,
  759.     },
  760.     {
  761.         .product_id = 0x902D,
  762.         .num_functions  = ARRAY_SIZE(usb_functions_rndis_adb_diag),
  763.         .functions  = usb_functions_rndis_adb_diag,
  764.     },
  765. };
  766. #else
  767.  
  768. #include "zte_usb_config.c"
  769.  
  770. #endif
  771.  
  772. static struct usb_mass_storage_platform_data mass_storage_pdata = {
  773.     .nluns      = 1,
  774.     .vendor     = "ZTE Incorporated",
  775.     .product        = "Mass storage",
  776.     .release    = 0x0100,
  777. };
  778.  
  779. static struct platform_device usb_mass_storage_device = {
  780.     .name   = "usb_mass_storage",
  781.     .id = -1,
  782.     .dev    = {
  783.         .platform_data = &mass_storage_pdata,
  784.     },
  785. };
  786.  
  787. #if 0
  788. static struct usb_ether_platform_data rndis_pdata = {
  789.     /* ethaddr is filled by board_serialno_setup */
  790.     .vendorID   = 0x05C6,
  791.     .vendorDescr    = "Qualcomm Incorporated",
  792. };
  793. #endif
  794. static struct platform_device rndis_device = {
  795.     .name   = "rndis",
  796.     .id = -1,
  797.     .dev    = {
  798.         .platform_data = &rndis_pdata,
  799.     },
  800. };
  801.  
  802. #if 0
  803. static struct android_usb_platform_data android_usb_pdata = {
  804.     .vendor_id  = 0x05C6,
  805.     .product_id = 0x9026,
  806.     .version    = 0x0100,
  807.     .product_name       = "Qualcomm HSUSB Device",
  808.     .manufacturer_name  = "Qualcomm Incorporated",
  809.     .num_products = ARRAY_SIZE(usb_products),
  810.     .products = usb_products,
  811.     .num_functions = ARRAY_SIZE(usb_functions_all),
  812.     .functions = usb_functions_all,
  813.     .serial_number = "1234567890ABCDEF",
  814. };
  815. #endif
  816. static struct platform_device android_usb_device = {
  817.     .name   = "android_usb",
  818.     .id     = -1,
  819.     .dev        = {
  820.         .platform_data = &android_usb_pdata,
  821.     },
  822. };
  823. #endif
  824.  
  825. #ifdef CONFIG_USB_MSM_OTG_72K
  826. static int hsusb_rpc_connect(int connect)
  827. {
  828.     if (connect)
  829.         return msm_hsusb_rpc_connect();
  830.     else
  831.         return msm_hsusb_rpc_close();
  832. }
  833. #endif
  834.  
  835. #ifdef CONFIG_USB_MSM_OTG_72K
  836. struct vreg *vreg_3p3;
  837. static int msm_hsusb_ldo_init(int init)
  838. {
  839.     if (init) {
  840.         vreg_3p3 = vreg_get(NULL, "usb");
  841.         if (IS_ERR(vreg_3p3))
  842.             return PTR_ERR(vreg_3p3);
  843.         vreg_set_level(vreg_3p3, 3300);
  844.     } else
  845.         vreg_put(vreg_3p3);
  846.  
  847.     return 0;
  848. }
  849.  
  850. static int msm_hsusb_ldo_enable(int enable)
  851. {
  852.     static int ldo_status;
  853.  
  854.     if (!vreg_3p3 || IS_ERR(vreg_3p3))
  855.         return -ENODEV;
  856.  
  857.     if (ldo_status == enable)
  858.         return 0;
  859.  
  860.     ldo_status = enable;
  861.  
  862.     pr_info("%s: %d", __func__, enable);
  863.  
  864.     if (enable)
  865.         return vreg_enable(vreg_3p3);
  866.  
  867.     return vreg_disable(vreg_3p3);
  868. }
  869.  
  870. static int msm_hsusb_pmic_notif_init(void (*callback)(int online), int init)
  871. {
  872.     int ret;
  873.  
  874.     if (init) {
  875.         ret = msm_pm_app_rpc_init(callback);
  876.     } else {
  877.         msm_pm_app_rpc_deinit(callback);
  878.         ret = 0;
  879.     }
  880.     return ret;
  881. }
  882.  
  883. //ruanmeisi_20100713 reset phy from arm9
  884. #ifdef  CONFIG_ZTE_PLATFORM
  885. static int msm_hsusb_rpc_phy_reset(void __iomem *addr)
  886. {
  887.         return msm_hsusb_phy_reset();
  888. }
  889. #endif
  890. static struct msm_otg_platform_data msm_otg_pdata = {
  891.     .rpc_connect    = hsusb_rpc_connect,
  892.     #ifdef CONFIG_ZTE_PLATFORM
  893.     .phy_reset      = msm_hsusb_rpc_phy_reset,
  894.     #endif
  895.     .pmic_vbus_notif_init         = msm_hsusb_pmic_notif_init,
  896.     .chg_vbus_draw       = hsusb_chg_vbus_draw,
  897.     .chg_connected       = hsusb_chg_connected,
  898.     .chg_init        = hsusb_chg_init,
  899. #ifdef CONFIG_USB_EHCI_MSM
  900.     .vbus_power = msm_hsusb_vbus_power,
  901. #endif
  902.     .ldo_init       = msm_hsusb_ldo_init,
  903.     .ldo_enable     = msm_hsusb_ldo_enable,
  904.     .pclk_required_during_lpm = 1
  905.  
  906. };
  907.  
  908. #ifdef CONFIG_USB_GADGET
  909. //static struct msm_hsusb_gadget_platform_data msm_gadget_pdata;
  910. #endif
  911. #endif
  912.  
  913. /* ZTE_Audio_CJ_100304, chenjun, 2010-3-4, start */
  914. #define SND(desc, num) { .name = #desc, .id = num }
  915. static struct snd_endpoint snd_endpoints_list[] = {
  916.     SND(HANDSET, 0),
  917.     SND(MONO_HEADSET, 2),
  918.     SND(HEADSET, 3),
  919. /* ZTE_Audio_CJ_101227, chenjun, 2010-12-27, start */
  920.     SND(HAC, 4),
  921. /* ZTE_Audio_CJ_101227, chenjun, 2010-12-27, end */
  922.     SND(SPEAKER, 6),
  923.     SND(TTY_HEADSET, 8),
  924.     SND(TTY_VCO, 9),
  925.     SND(TTY_HCO, 10),
  926.     SND(BT, 12),
  927.     SND(IN_S_SADC_OUT_HANDSET, 16),
  928.     SND(IN_S_SADC_OUT_SPEAKER_PHONE, 25),
  929.     SND(HEADSET_AND_SPEAKER, 26),
  930.     SND(CURRENT, 28),
  931. };
  932. #undef SND
  933. /* ZTE_Audio_CJ_100304, chenjun, 2010-3-4, end */
  934.  
  935. static struct msm_snd_endpoints msm_device_snd_endpoints = {
  936.     .endpoints = snd_endpoints_list,
  937.     .num = sizeof(snd_endpoints_list) / sizeof(struct snd_endpoint)
  938. };
  939.  
  940. static struct platform_device msm_device_snd = {
  941.     .name = "msm_snd",
  942.     .id = -1,
  943.     .dev    = {
  944.         .platform_data = &msm_device_snd_endpoints
  945.     },
  946. };
  947.  
  948. #define DEC0_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
  949.     (1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
  950.     (1<<MSM_ADSP_CODEC_WMAPRO)|(1<<MSM_ADSP_CODEC_AMRWB)| \
  951.     (1<<MSM_ADSP_CODEC_AMRNB)|(1<<MSM_ADSP_CODEC_WAV)| \
  952.     (1<<MSM_ADSP_CODEC_ADPCM)|(1<<MSM_ADSP_CODEC_YADPCM)| \
  953.     (1<<MSM_ADSP_CODEC_EVRC)|(1<<MSM_ADSP_CODEC_QCELP))
  954. #define DEC1_FORMAT ((1<<MSM_ADSP_CODEC_WAV)|(1<<MSM_ADSP_CODEC_ADPCM)| \
  955.     (1<<MSM_ADSP_CODEC_YADPCM)|(1<<MSM_ADSP_CODEC_QCELP)| \
  956.     (1<<MSM_ADSP_CODEC_MP3))
  957. #define DEC2_FORMAT ((1<<MSM_ADSP_CODEC_WAV)|(1<<MSM_ADSP_CODEC_ADPCM)| \
  958.     (1<<MSM_ADSP_CODEC_YADPCM)|(1<<MSM_ADSP_CODEC_QCELP)| \
  959.     (1<<MSM_ADSP_CODEC_MP3))
  960.  
  961. #ifdef CONFIG_ARCH_MSM7X25
  962. #define DEC3_FORMAT 0
  963. #define DEC4_FORMAT 0
  964. #else
  965. #define DEC3_FORMAT ((1<<MSM_ADSP_CODEC_WAV)|(1<<MSM_ADSP_CODEC_ADPCM)| \
  966.     (1<<MSM_ADSP_CODEC_YADPCM)|(1<<MSM_ADSP_CODEC_QCELP))
  967. #define DEC4_FORMAT (1<<MSM_ADSP_CODEC_MIDI)
  968. #endif
  969.  
  970. static unsigned int dec_concurrency_table[] = {
  971.     /* Audio LP */
  972.     (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DMA)), 0,
  973.     0, 0, 0,
  974.  
  975.     /* Concurrency 1 */
  976.     (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
  977.     (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
  978.     (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
  979.     (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
  980.     (DEC4_FORMAT),
  981.  
  982.      /* Concurrency 2 */
  983.     (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
  984.     (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
  985.     (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
  986.     (DEC3_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
  987.     (DEC4_FORMAT),
  988.  
  989.     /* Concurrency 3 */
  990.     (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
  991.     (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
  992.     (DEC2_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
  993.     (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
  994.     (DEC4_FORMAT),
  995.  
  996.     /* Concurrency 4 */
  997.     (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
  998.     (DEC1_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
  999.     (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
  1000.     (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
  1001.     (DEC4_FORMAT),
  1002.  
  1003.     /* Concurrency 5 */
  1004.     (DEC0_FORMAT|(1<<MSM_ADSP_MODE_TUNNEL)|(1<<MSM_ADSP_OP_DM)),
  1005.     (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
  1006.     (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
  1007.     (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
  1008.     (DEC4_FORMAT),
  1009.  
  1010.     /* Concurrency 6 */
  1011.     (DEC0_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
  1012.     (DEC1_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
  1013.     (DEC2_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
  1014.     (DEC3_FORMAT|(1<<MSM_ADSP_MODE_NONTUNNEL)|(1<<MSM_ADSP_OP_DM)),
  1015.     (DEC4_FORMAT),
  1016. };
  1017.  
  1018. #define DEC_INFO(name, queueid, decid, nr_codec) { .module_name = name, \
  1019.     .module_queueid = queueid, .module_decid = decid, \
  1020.     .nr_codec_support = nr_codec}
  1021.  
  1022. static struct msm_adspdec_info dec_info_list[] = {
  1023.     DEC_INFO("AUDPLAY0TASK", 13, 0, 11), /* AudPlay0BitStreamCtrlQueue */
  1024.     DEC_INFO("AUDPLAY1TASK", 14, 1, 5),  /* AudPlay1BitStreamCtrlQueue */
  1025.     DEC_INFO("AUDPLAY2TASK", 15, 2, 5),  /* AudPlay2BitStreamCtrlQueue */
  1026. #ifdef CONFIG_ARCH_MSM7X25
  1027.     DEC_INFO("AUDPLAY3TASK", 16, 3, 0),  /* AudPlay3BitStreamCtrlQueue */
  1028.     DEC_INFO("AUDPLAY4TASK", 17, 4, 0),  /* AudPlay4BitStreamCtrlQueue */
  1029. #else
  1030.     DEC_INFO("AUDPLAY3TASK", 16, 3, 4),  /* AudPlay3BitStreamCtrlQueue */
  1031.     DEC_INFO("AUDPLAY4TASK", 17, 4, 1),  /* AudPlay4BitStreamCtrlQueue */
  1032. #endif
  1033. };
  1034.  
  1035. static struct msm_adspdec_database msm_device_adspdec_database = {
  1036.     .num_dec = ARRAY_SIZE(dec_info_list),
  1037.     .num_concurrency_support = (ARRAY_SIZE(dec_concurrency_table) / \
  1038.                     ARRAY_SIZE(dec_info_list)),
  1039.     .dec_concurrency_table = dec_concurrency_table,
  1040.     .dec_info_list = dec_info_list,
  1041. };
  1042.  
  1043. static struct platform_device msm_device_adspdec = {
  1044.     .name = "msm_adspdec",
  1045.     .id = -1,
  1046.     .dev    = {
  1047.         .platform_data = &msm_device_adspdec_database
  1048.     },
  1049. };
  1050.  
  1051. static struct android_pmem_platform_data android_pmem_kernel_ebi1_pdata = {
  1052.     .name = PMEM_KERNEL_EBI1_DATA_NAME,
  1053.     /* if no allocator_type, defaults to PMEM_ALLOCATORTYPE_BITMAP,
  1054.      * the only valid choice at this time. The board structure is
  1055.      * set to all zeros by the C runtime initialization and that is now
  1056.      * the enum value of PMEM_ALLOCATORTYPE_BITMAP, now forced to 0 in
  1057.      * include/linux/android_pmem.h.
  1058.      */
  1059.     .cached = 0,
  1060. };
  1061.  
  1062. static struct android_pmem_platform_data android_pmem_pdata = {
  1063.     .name = "pmem",
  1064.     .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
  1065.     .cached = 1,
  1066. };
  1067.  
  1068. static struct android_pmem_platform_data android_pmem_adsp_pdata = {
  1069.     .name = "pmem_adsp",
  1070.     .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
  1071.     .cached = 0,
  1072. };
  1073.  
  1074. static struct android_pmem_platform_data android_pmem_audio_pdata = {
  1075.     .name = "pmem_audio",
  1076.     .allocator_type = PMEM_ALLOCATORTYPE_BITMAP,
  1077.     .cached = 0,
  1078. };
  1079.  
  1080. static struct platform_device android_pmem_device = {
  1081.     .name = "android_pmem",
  1082.     .id = 0,
  1083.     .dev = { .platform_data = &android_pmem_pdata },
  1084. };
  1085.  
  1086. static struct platform_device android_pmem_adsp_device = {
  1087.     .name = "android_pmem",
  1088.     .id = 1,
  1089.     .dev = { .platform_data = &android_pmem_adsp_pdata },
  1090. };
  1091.  
  1092. static struct platform_device android_pmem_audio_device = {
  1093.     .name = "android_pmem",
  1094.     .id = 2,
  1095.     .dev = { .platform_data = &android_pmem_audio_pdata },
  1096. };
  1097.  
  1098. static struct platform_device android_pmem_kernel_ebi1_device = {
  1099.     .name = "android_pmem",
  1100.     .id = 4,
  1101.     .dev = { .platform_data = &android_pmem_kernel_ebi1_pdata },
  1102. };
  1103.  
  1104. static struct msm_handset_platform_data hs_platform_data = {
  1105.     .hs_name = "7k_handset",
  1106.     .pwr_key_delay_ms = 500, /* 0 will disable end key */
  1107. };
  1108.  
  1109. static struct platform_device hs_device = {
  1110.     .name   = "msm-handset",
  1111.     .id     = -1,
  1112.     .dev    = {
  1113.         .platform_data = &hs_platform_data,
  1114.     },
  1115. };
  1116.  
  1117.  
  1118. #define LCDC_CONFIG_PROC          21
  1119. #define LCDC_UN_CONFIG_PROC       22
  1120. #define LCDC_API_PROG             0x30000066
  1121. #define LCDC_API_VERS             0x00010001
  1122.  
  1123. //ZTE_BOOT_HUANGYJ_20100816_01 add mooncake boot config
  1124. #ifdef CONFIG_ZTE_PLATFORM
  1125. //lcd reset & spi
  1126. #define GPIO_LCD_RESET_OUT      91
  1127. #define GPIO_LCD_SPI_CS_OUT     122
  1128. #define GPIO_LCD_SPI_SDO_OUT    123
  1129. #define GPIO_LCD_SPI_SCLK_OUT   124
  1130. #define GPIO_LCD_SPI_SDI_IN     132
  1131. #define GPIO_LCD_ID_DETECT      34//ZTE_LCD_LKEJ_20110225_001
  1132.  
  1133. #else
  1134. #define GPIO_OUT_132    132
  1135. #define GPIO_OUT_131    131
  1136. #define GPIO_OUT_103    103
  1137. #define GPIO_OUT_102    102
  1138. #define GPIO_OUT_88     88
  1139. #endif
  1140.  
  1141. static struct msm_rpc_endpoint *lcdc_ep;
  1142.  
  1143. static int msm_fb_lcdc_config(int on)
  1144. {
  1145.     int rc = 0;
  1146.     struct rpc_request_hdr hdr;
  1147.  
  1148.     if (on)
  1149.         pr_info("lcdc config\n");
  1150.     else
  1151.         pr_info("lcdc un-config\n");
  1152.  
  1153.     lcdc_ep = msm_rpc_connect_compatible(LCDC_API_PROG, LCDC_API_VERS, 0);
  1154.     if (IS_ERR(lcdc_ep)) {
  1155.         printk(KERN_ERR "%s: msm_rpc_connect failed! rc = %ld\n",
  1156.             __func__, PTR_ERR(lcdc_ep));
  1157.         return -EINVAL;
  1158.     }
  1159.  
  1160.     rc = msm_rpc_call(lcdc_ep,
  1161.                 (on) ? LCDC_CONFIG_PROC : LCDC_UN_CONFIG_PROC,
  1162.                 &hdr, sizeof(hdr),
  1163.                 5 * HZ);
  1164.     if (rc)
  1165.         printk(KERN_ERR
  1166.             "%s: msm_rpc_call failed! rc = %d\n", __func__, rc);
  1167.  
  1168.     msm_rpc_close(lcdc_ep);
  1169.     return rc;
  1170. }
  1171.  
  1172. //ZTE_BOOT_HUANGYJ_20100816_01 add mooncake boot config
  1173. #ifdef CONFIG_ZTE_PLATFORM
  1174. static int gpio_array_num[] = {
  1175.                 GPIO_LCD_SPI_SCLK_OUT, /* spi_clk */
  1176.                 GPIO_LCD_SPI_CS_OUT, /* spi_cs  */
  1177.                 GPIO_LCD_SPI_SDI_IN, /* spi_sdi */
  1178.                 GPIO_LCD_SPI_SDO_OUT, /* spi_sdoi */
  1179.                 GPIO_LCD_RESET_OUT,
  1180.                 GPIO_LCD_ID_DETECT,//ZTE_LCD_LKEJ_20110225_001
  1181.                 };
  1182.  
  1183. static void lcdc_lead_gpio_init(void)
  1184. {
  1185.     if (gpio_request(GPIO_LCD_SPI_SCLK_OUT, "spi_clk"))
  1186.         pr_err("failed to request gpio spi_clk\n");
  1187.     if (gpio_request(GPIO_LCD_SPI_CS_OUT, "spi_cs"))
  1188.         pr_err("failed to request gpio spi_cs\n");
  1189.     if (gpio_request(GPIO_LCD_SPI_SDI_IN, "spi_sdi"))
  1190.         pr_err("failed to request gpio spi_sdi\n");
  1191.     if (gpio_request(GPIO_LCD_SPI_SDO_OUT, "spi_sdoi"))
  1192.         pr_err("failed to request gpio spi_sdoi\n");
  1193.     if (gpio_request(GPIO_LCD_RESET_OUT, "gpio_dac"))
  1194.         pr_err("failed to request gpio_dac\n");
  1195.     if (gpio_request(GPIO_LCD_ID_DETECT, "gpio_id_detect"))//ZTE_LCD_LKEJ_20110225_001
  1196.         pr_err("failed to request gpio_id_detect\n");
  1197. }
  1198.  
  1199. static uint32_t lcdc_gpio_table[] = {
  1200.     GPIO_CFG(GPIO_LCD_SPI_SCLK_OUT, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_2MA),
  1201.     GPIO_CFG(GPIO_LCD_SPI_CS_OUT, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_2MA),
  1202.     GPIO_CFG(GPIO_LCD_SPI_SDI_IN, 0, GPIO_INPUT, GPIO_PULL_UP, GPIO_2MA),
  1203.     GPIO_CFG(GPIO_LCD_SPI_SDO_OUT, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_2MA),
  1204.     GPIO_CFG(GPIO_LCD_RESET_OUT,  0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_2MA),
  1205.     GPIO_CFG(GPIO_LCD_ID_DETECT, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_2MA),};//ZTE_LCD_LKEJ_20110225_001
  1206. #else
  1207. static int gpio_array_num[] = {
  1208.                 GPIO_OUT_132, /* spi_clk */
  1209.                 GPIO_OUT_131, /* spi_cs  */
  1210.                 GPIO_OUT_103, /* spi_sdi */
  1211.                 GPIO_OUT_102, /* spi_sdoi */
  1212.                 GPIO_OUT_88
  1213.                 };
  1214.  
  1215. static void lcdc_gordon_gpio_init(void)
  1216. {
  1217.     if (gpio_request(GPIO_OUT_132, "spi_clk"))
  1218.         pr_err("failed to request gpio spi_clk\n");
  1219.     if (gpio_request(GPIO_OUT_131, "spi_cs"))
  1220.         pr_err("failed to request gpio spi_cs\n");
  1221.     if (gpio_request(GPIO_OUT_103, "spi_sdi"))
  1222.         pr_err("failed to request gpio spi_sdi\n");
  1223.     if (gpio_request(GPIO_OUT_102, "spi_sdoi"))
  1224.         pr_err("failed to request gpio spi_sdoi\n");
  1225.     if (gpio_request(GPIO_OUT_88, "gpio_dac"))
  1226.         pr_err("failed to request gpio_dac\n");
  1227. }
  1228.  
  1229. static uint32_t lcdc_gpio_table[] = {
  1230.     GPIO_CFG(GPIO_OUT_132, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_2MA),
  1231.     GPIO_CFG(GPIO_OUT_131, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_2MA),
  1232.     GPIO_CFG(GPIO_OUT_103, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_2MA),
  1233.     GPIO_CFG(GPIO_OUT_102, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_2MA),
  1234.     GPIO_CFG(GPIO_OUT_88,  0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_2MA),
  1235. };
  1236. #endif
  1237.  
  1238. static void config_lcdc_gpio_table(uint32_t *table, int len, unsigned enable)
  1239. {
  1240.     int n, rc;
  1241.     for (n = 0; n < len; n++) {
  1242.         rc = gpio_tlmm_config(table[n],
  1243.             enable ? GPIO_ENABLE : GPIO_DISABLE);
  1244.         if (rc) {
  1245.             printk(KERN_ERR "%s: gpio_tlmm_config(%#x)=%d\n",
  1246.                 __func__, table[n], rc);
  1247.             break;
  1248.         }
  1249.     }
  1250. }
  1251.  
  1252. //ZTE_BOOT_HUANGYJ_20100816_01 add mooncake boot config
  1253. #ifdef CONFIG_ZTE_PLATFORM
  1254. static void lcdc_lead_config_gpios(int enable)
  1255. #else
  1256. static void lcdc_gordon_config_gpios(int enable)
  1257. #endif
  1258. {
  1259.     config_lcdc_gpio_table(lcdc_gpio_table,
  1260.         ARRAY_SIZE(lcdc_gpio_table), enable);
  1261. }
  1262.  
  1263. static char *msm_fb_lcdc_vreg[] = {
  1264.     "gp5"
  1265. };
  1266.  
  1267. static int msm_fb_lcdc_power_save(int on)
  1268. {
  1269.     struct vreg *vreg[ARRAY_SIZE(msm_fb_lcdc_vreg)];
  1270.     int i, rc = 0;
  1271.  
  1272.     for (i = 0; i < ARRAY_SIZE(msm_fb_lcdc_vreg); i++) {
  1273.         if (on) {
  1274.             vreg[i] = vreg_get(0, msm_fb_lcdc_vreg[i]);
  1275.             rc = vreg_enable(vreg[i]);
  1276.             if (rc) {
  1277.                 printk(KERN_ERR "vreg_enable: %s vreg"
  1278.                         "operation failed \n",
  1279.                         msm_fb_lcdc_vreg[i]);
  1280.                 goto bail;
  1281.             }
  1282.            if(lcd_first_reset)//ZTE_DRIVE_LCD_LKEJ_20110620
  1283.             {
  1284.              lcdc_lead_config_gpios(1);
  1285.              msleep(10);
  1286.              gpio_direction_output(GPIO_LCD_RESET_OUT, 1);
  1287.              msleep(10);                        ////ZTE_LCD_LUYA_20100629_001
  1288.              gpio_direction_output(GPIO_LCD_RESET_OUT, 0);
  1289.              msleep(20);                        ////ZTE_LCD_LUYA_20100629_001
  1290.              gpio_direction_output(GPIO_LCD_RESET_OUT, 1);
  1291.              msleep(120);
  1292.             }
  1293.            else
  1294.             {
  1295.               lcd_first_reset = true;
  1296.             }
  1297.         } else {
  1298.             int tmp;
  1299.             vreg[i] = vreg_get(0, msm_fb_lcdc_vreg[i]);
  1300.             tmp = vreg_disable(vreg[i]);
  1301.             if (tmp) {
  1302.                 printk(KERN_ERR "vreg_disable: %s vreg "
  1303.                         "operation failed \n",
  1304.                         msm_fb_lcdc_vreg[i]);
  1305.                 if (!rc)
  1306.                     rc = tmp;
  1307.             }
  1308.             /*
  1309.             tmp = gpio_tlmm_config(GPIO_CFG(GPIO_LCD_RESET_OUT, 0,
  1310.                         GPIO_OUTPUT, GPIO_NO_PULL,
  1311.                         GPIO_2MA), GPIO_ENABLE);
  1312.             if (tmp) {
  1313.                 printk(KERN_ERR "gpio_tlmm_config failed\n");
  1314.                 if (!rc)
  1315.                     rc = tmp;
  1316.             }
  1317.             gpio_set_value(91, 0);
  1318.             mdelay(15);
  1319.             gpio_set_value(91, 1);
  1320.             mdelay(15);
  1321.             */
  1322.         }
  1323.     }
  1324.  
  1325.     return rc;
  1326.  
  1327. bail:
  1328.     if (on) {
  1329.         for (; i > 0; i--)
  1330.             vreg_disable(vreg[i - 1]);
  1331.     }
  1332.  
  1333.     return rc;
  1334. }
  1335. static struct lcdc_platform_data lcdc_pdata = {
  1336.     .lcdc_gpio_config = msm_fb_lcdc_config,
  1337.     .lcdc_power_save   = msm_fb_lcdc_power_save,
  1338. };
  1339.  
  1340. //ZTE_BOOT_HUANGYJ_20100816_01 add mooncake boot config
  1341. #ifdef CONFIG_ZTE_PLATFORM
  1342. static struct msm_panel_common_pdata lcdc_qvga_panel_data = {
  1343.     .panel_config_gpio = lcdc_lead_config_gpios,
  1344.     .gpio_num          = gpio_array_num,
  1345. };
  1346.  
  1347. static struct platform_device lcdc_qvga_panel_device = {
  1348.     .name   = "lcdc_panel_qvga",
  1349.     .id     = 0,
  1350.     .dev    = {
  1351.         .platform_data = &lcdc_qvga_panel_data,
  1352.     }
  1353. };
  1354. #else
  1355. static struct msm_panel_common_pdata lcdc_gordon_panel_data = {
  1356.     .panel_config_gpio = lcdc_gordon_config_gpios,
  1357.     .gpio_num          = gpio_array_num,
  1358. };
  1359.  
  1360. static struct platform_device lcdc_gordon_panel_device = {
  1361.     .name   = "lcdc_gordon_vga",
  1362.     .id     = 0,
  1363.     .dev    = {
  1364.         .platform_data = &lcdc_gordon_panel_data,
  1365.     }
  1366. };
  1367. #endif
  1368.  
  1369. static struct resource msm_fb_resources[] = {
  1370.     {
  1371.         .flags  = IORESOURCE_DMA,
  1372.     }
  1373. };
  1374.  
  1375. static int msm_fb_detect_panel(const char *name)
  1376. {
  1377.     int ret = -EPERM;
  1378.  
  1379.     if (machine_is_msm7x25_ffa() || machine_is_msm7x27_ffa()) {
  1380.         if (!strcmp(name, "lcdc_gordon_vga"))
  1381.             ret = 0;
  1382.         else
  1383.             ret = -ENODEV;
  1384.     }
  1385.  
  1386.     return ret;
  1387. }
  1388.  
  1389. static struct msm_fb_platform_data msm_fb_pdata = {
  1390.     .detect_client = msm_fb_detect_panel,
  1391.     .mddi_prescan = 1,
  1392. };
  1393.  
  1394. static struct platform_device msm_fb_device = {
  1395.     .name   = "msm_fb",
  1396.     .id     = 0,
  1397.     .num_resources  = ARRAY_SIZE(msm_fb_resources),
  1398.     .resource       = msm_fb_resources,
  1399.     .dev    = {
  1400.         .platform_data = &msm_fb_pdata,
  1401.     }
  1402. };
  1403.  
  1404. #ifdef CONFIG_BT
  1405. static struct platform_device msm_bt_power_device = {
  1406.     .name = "bt_power",
  1407. };
  1408.  
  1409.  
  1410. static struct platform_device msm_bcm_power_device = {
  1411.     .name = "bcm_power",
  1412. };
  1413.  
  1414.  
  1415. enum {
  1416.     BT_WAKE,
  1417.     BT_RFR,
  1418.     BT_CTS,
  1419.     BT_RX,
  1420.     BT_TX,
  1421.     BT_PCM_DOUT,
  1422.     BT_PCM_DIN,
  1423.     BT_PCM_SYNC,
  1424.     BT_PCM_CLK,
  1425.     BT_HOST_WAKE,
  1426. };
  1427.  
  1428. static unsigned bt_config_power_on[] = {
  1429.     GPIO_CFG(90, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_2MA),   /* WAKE ZTE_BT_QXX_20100709*/
  1430.     GPIO_CFG(43, 2, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_2MA),   /* RFR */
  1431.     GPIO_CFG(44, 2, GPIO_INPUT,  GPIO_NO_PULL, GPIO_2MA),   /* CTS */
  1432.     GPIO_CFG(45, 2, GPIO_INPUT,  GPIO_NO_PULL, GPIO_2MA),   /* Rx */
  1433.     GPIO_CFG(46, 3, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_2MA),   /* Tx */
  1434.     GPIO_CFG(68, 1, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_2MA),   /* PCM_DOUT */
  1435.     GPIO_CFG(69, 1, GPIO_INPUT,  GPIO_NO_PULL, GPIO_2MA),   /* PCM_DIN */
  1436.     GPIO_CFG(70, 2, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_2MA),   /* PCM_SYNC */
  1437.     GPIO_CFG(71, 2, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_2MA),   /* PCM_CLK */
  1438.     GPIO_CFG(83, 0, GPIO_INPUT,  GPIO_NO_PULL, GPIO_2MA),   /* HOST_WAKE */
  1439. };
  1440. static unsigned bt_config_power_off[] = {
  1441.     GPIO_CFG(90, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA),  /* WAKE */
  1442.     GPIO_CFG(43, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA),  /* RFR */
  1443.     GPIO_CFG(44, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA),  /* CTS */
  1444.     GPIO_CFG(45, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA),  /* Rx */
  1445.     GPIO_CFG(46, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA),  /* Tx */
  1446.     GPIO_CFG(68, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA),  /* PCM_DOUT */
  1447.     GPIO_CFG(69, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA),  /* PCM_DIN */
  1448.     GPIO_CFG(70, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA),  /* PCM_SYNC */
  1449.     GPIO_CFG(71, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA),  /* PCM_CLK */
  1450.     GPIO_CFG(83, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA),  /* HOST_WAKE */
  1451. };
  1452.  
  1453. static int bluetooth_power(int on)
  1454. {
  1455.     struct vreg *vreg_bt;
  1456.     int pin, rc;
  1457.  
  1458.     printk(KERN_DEBUG "%s\n", __func__);
  1459.  
  1460.     /* do not have vreg bt defined, gp6 is the same */
  1461.     /* vreg_get parameter 1 (struct device *) is ignored */
  1462.     vreg_bt = vreg_get(NULL, "gp6");
  1463.  
  1464.     if (IS_ERR(vreg_bt)) {
  1465.         printk(KERN_ERR "%s: vreg get failed (%ld)\n",
  1466.                __func__, PTR_ERR(vreg_bt));
  1467.         return PTR_ERR(vreg_bt);
  1468.     }
  1469.  
  1470.     if (on) {
  1471.         for (pin = 0; pin < ARRAY_SIZE(bt_config_power_on); pin++) {
  1472.             rc = gpio_tlmm_config(bt_config_power_on[pin],
  1473.                           GPIO_ENABLE);
  1474.             if (rc) {
  1475.                 printk(KERN_ERR
  1476.                        "%s: gpio_tlmm_config(%#x)=%d\n",
  1477.                        __func__, bt_config_power_on[pin], rc);
  1478.                 return -EIO;
  1479.             }
  1480.         }
  1481.  
  1482.         /* units of mV, steps of 50 mV */
  1483.         rc = vreg_set_level(vreg_bt, 1800);
  1484.         if (rc) {
  1485.             printk(KERN_ERR "%s: vreg set level failed (%d)\n",
  1486.                    __func__, rc);
  1487.             return -EIO;
  1488.         }
  1489.         rc = vreg_enable(vreg_bt);
  1490.         if (rc) {
  1491.             printk(KERN_ERR "%s: vreg enable failed (%d)\n",
  1492.                    __func__, rc);
  1493.             return -EIO;
  1494.         }
  1495.        
  1496.         rc = gpio_request(20, "bt_reset");
  1497.         if(!rc)
  1498.         {
  1499.             gpio_direction_output(20, 1);
  1500.         }
  1501.         else
  1502.         {
  1503.             printk(KERN_ERR "gpio_request: %d failed!\n", 20);
  1504.         }
  1505.         gpio_free(20);     
  1506.        
  1507.     } else {
  1508.         rc = vreg_disable(vreg_bt);
  1509.         if (rc) {
  1510.             printk(KERN_ERR "%s: vreg disable failed (%d)\n",
  1511.                    __func__, rc);
  1512.             return -EIO;
  1513.         }
  1514.         for (pin = 0; pin < ARRAY_SIZE(bt_config_power_off); pin++) {
  1515.             rc = gpio_tlmm_config(bt_config_power_off[pin],
  1516.                           GPIO_ENABLE);
  1517.             if (rc) {
  1518.                 printk(KERN_ERR
  1519.                        "%s: gpio_tlmm_config(%#x)=%d\n",
  1520.                        __func__, bt_config_power_off[pin], rc);
  1521.                 return -EIO;
  1522.             }
  1523.         }
  1524.        
  1525.     rc = gpio_request(20, "bt_reset");
  1526.     if(!rc)
  1527.     {
  1528.         gpio_direction_output(20, 0);
  1529.     }
  1530.     else
  1531.     {
  1532.         printk(KERN_ERR "gpio_request: %d failed!\n", 20);
  1533.     }
  1534.     gpio_free(20);
  1535.        
  1536.     }
  1537.     return 0;
  1538. }
  1539.  
  1540.  
  1541. static int bcm_power(int on)
  1542. {
  1543. //  struct vreg *vreg_bt;  
  1544.     int pin, rc;
  1545.  
  1546.     printk(KERN_DEBUG "%s\n", __func__);
  1547.  
  1548.     if (on) {
  1549.         for (pin = 0; pin < ARRAY_SIZE(bt_config_power_on); pin++) {
  1550.             rc = gpio_tlmm_config(bt_config_power_on[pin],
  1551.                           GPIO_ENABLE);
  1552.             if (rc) {
  1553.                 printk(KERN_ERR
  1554.                        "%s: gpio_tlmm_config(%#x)=%d\n",
  1555.                        __func__, bt_config_power_on[pin], rc);
  1556.                 return -EIO;
  1557.             }
  1558.         }
  1559.  
  1560.        
  1561.         rc = gpio_request(20, "bt_reset");
  1562.         if(!rc)
  1563.         {
  1564.        gpio_direction_output(20, 0);
  1565.            mdelay(1);
  1566.            gpio_direction_output(20, 1);
  1567.    
  1568.         }
  1569.         else
  1570.         {
  1571.             printk(KERN_ERR "gpio_request: %d failed!\n", 20);
  1572.         }
  1573.         gpio_free(20);     
  1574.        
  1575.     } else {
  1576.    
  1577.         for (pin = 0; pin < ARRAY_SIZE(bt_config_power_off); pin++) {
  1578.             rc = gpio_tlmm_config(bt_config_power_off[pin],
  1579.                           GPIO_ENABLE);
  1580.             if (rc) {
  1581.                 printk(KERN_ERR
  1582.                        "%s: gpio_tlmm_config(%#x)=%d\n",
  1583.                        __func__, bt_config_power_off[pin], rc);
  1584.                 return -EIO;
  1585.             }
  1586.         }
  1587.        
  1588.     rc = gpio_request(20, "bt_reset");
  1589.     if(!rc)
  1590.     {
  1591.         gpio_direction_output(20, 0);
  1592.     }
  1593.     else
  1594.     {
  1595.        printk(KERN_ERR "gpio_request: %d failed!\n", 20);
  1596.     }
  1597.     gpio_free(20);
  1598.        
  1599.     }
  1600.     return 0;
  1601. }
  1602.  
  1603.  
  1604. static void __init bt_power_init(void)
  1605. {
  1606.     msm_bt_power_device.dev.platform_data = &bluetooth_power;
  1607.     msm_bcm_power_device.dev.platform_data = &bcm_power;  
  1608. }
  1609. #else
  1610. #define bt_power_init(x) do {} while (0)
  1611. #endif
  1612.  
  1613. #ifdef CONFIG_ARCH_MSM7X27
  1614. static struct resource kgsl_resources[] = {
  1615.     {
  1616.         .name = "kgsl_reg_memory",
  1617.         .start = 0xA0000000,
  1618.         .end = 0xA001ffff,
  1619.         .flags = IORESOURCE_MEM,
  1620.     },
  1621.     {
  1622.         .name = "kgsl_yamato_irq",
  1623.         .start = INT_GRAPHICS,
  1624.         .end = INT_GRAPHICS,
  1625.         .flags = IORESOURCE_IRQ,
  1626.     },
  1627. };
  1628.  
  1629. static struct kgsl_platform_data kgsl_pdata;
  1630.  
  1631. static struct platform_device msm_device_kgsl = {
  1632.     .name = "kgsl",
  1633.     .id = -1,
  1634.     .num_resources = ARRAY_SIZE(kgsl_resources),
  1635.     .resource = kgsl_resources,
  1636.     .dev = {
  1637.         .platform_data = &kgsl_pdata,
  1638.     },
  1639. };
  1640. #endif
  1641.  
  1642. static struct platform_device msm_device_pmic_leds = {
  1643.     .name   = "pmic-leds-status",
  1644.     .id = -1,
  1645. };
  1646.  
  1647. /*ZTE_BUTTON_BACKLIGHT_WLY_005, @2009-11-1,change gpio89 to gpio32,begin*/
  1648. static struct gpio_led android_led_list[] = {
  1649.     {
  1650.         .name = "button-backlight",
  1651.         .gpio = 35,
  1652.     },
  1653. };
  1654.  
  1655. static struct gpio_led_platform_data android_leds_data = {
  1656.     .num_leds   = ARRAY_SIZE(android_led_list),
  1657.     .leds       = android_led_list,
  1658. };
  1659.  
  1660. static struct platform_device android_leds = {
  1661.     .name       = "leds-gpio",
  1662.     .id     = -1,
  1663.     .dev        = {
  1664.         .platform_data = &android_leds_data,
  1665.     },
  1666. };
  1667. /*ZTE_BUTTON_BACKLIGHT_WLY_005, @2009-11-1,change gpio89 to gpio32,end*/
  1668.  
  1669. static struct resource bluesleep_resources[] = {
  1670.     {
  1671.         .name   = "gpio_host_wake",
  1672.         .start  = 83,
  1673.         .end    = 83,
  1674.         .flags  = IORESOURCE_IO,
  1675.     },
  1676.     {
  1677.         .name   = "gpio_ext_wake",
  1678.         .start  = 90,  
  1679.         .end    = 90,    
  1680.         .flags  = IORESOURCE_IO,
  1681.     },
  1682.     {
  1683.         .name   = "host_wake",
  1684.         .start  = MSM_GPIO_TO_INT(83),
  1685.         .end    = MSM_GPIO_TO_INT(83),
  1686.         .flags  = IORESOURCE_IRQ,
  1687.     },
  1688. };
  1689.  
  1690. static struct platform_device msm_bluesleep_device = {
  1691.     .name = "bluesleep",
  1692.     .id     = -1,
  1693.     .num_resources  = ARRAY_SIZE(bluesleep_resources),
  1694.     .resource   = bluesleep_resources,
  1695. };
  1696.  
  1697.  
  1698. static struct platform_device msm_bcmsleep_device = {
  1699.     .name = "bcmsleep",
  1700.     .id     = -1,
  1701.     .num_resources  = ARRAY_SIZE(bluesleep_resources),
  1702.     .resource   = bluesleep_resources,
  1703. };
  1704.  
  1705. #ifdef CONFIG_TOUCHSCREEN_SYNAPTICS_3K
  1706. #define SYNAPTICS_I2C_RMI4_NAME "synaptics-rmi4-ts"
  1707. #define TS_I2C_ADDR     0x22
  1708. #define GPIO_TS_IRQ     29
  1709. #define GPIO_TOUCH_EN   31
  1710.  
  1711. static int touchscreen_power(int on)
  1712. {
  1713.     int ret=0;
  1714.     ret = gpio_request(GPIO_TOUCH_EN, "touch voltage");
  1715.     if (!ret){
  1716.         if (on==1){
  1717.             gpio_direction_output(GPIO_TOUCH_EN, 1);
  1718.         }else if (on==0){
  1719.             gpio_direction_output(GPIO_TOUCH_EN,0);
  1720.     }
  1721.     }else{
  1722.         pr_err("touchscreen_power,gpio request error!\n");
  1723.         ret=-EIO;
  1724.     }
  1725.  
  1726.     gpio_free(GPIO_TOUCH_EN);
  1727.  
  1728.     return ret;
  1729. }
  1730.  
  1731. static struct synaptics_rmi4_data synaptics_ts_data = {
  1732.     .orientation    = 0,    // ROTATION_0 = 0,ROTATION_90 = 1, ROTATION_180 = 2, ROTATION_270 = 3
  1733.     .power  = touchscreen_power,
  1734.     .gpio_irq = 29,
  1735. };
  1736.  
  1737. #endif
  1738.  
  1739. static struct lis302dl_platform_data gsensor = {
  1740.     .gpio_intr1 =  84,
  1741.     .gpio_intr2 =  85,
  1742.     .scale      =  2 ,
  1743.     .int_active_low = 1,
  1744. };
  1745.  
  1746. static struct i2c_board_info i2c_devices[] = {
  1747. //add the following devices to i2c-bus     ZTE_SENSORS_FYA_20110223 begin
  1748. #ifdef CONFIG_SENSORS_AKM8962
  1749.     {
  1750.         I2C_BOARD_INFO("akm8962", 0x0c),
  1751.     },
  1752. #endif
  1753. #ifdef CONFIG_SENSOR_LIS302DL
  1754.     {
  1755.         .type = "lis302dl",
  1756.         .addr = 0x1c,
  1757.         .platform_data = &gsensor,
  1758.     },
  1759. #endif
  1760. #ifdef CONFIG_SENSOR_ADXL34X   
  1761.     {  
  1762.         .type = "adxl34x",  
  1763.         .addr = 0x53,  
  1764.     },
  1765. #endif
  1766. //add the following devices to i2c-bus     ZTE_SENSORS_FYA_20110223 end
  1767. #ifdef CONFIG_MT9D112
  1768.     {
  1769.         I2C_BOARD_INFO("mt9d112", 0x78 >> 1),
  1770.     },
  1771. #endif
  1772. #ifdef CONFIG_S5K3E2FX
  1773.     {
  1774.         I2C_BOARD_INFO("s5k3e2fx", 0x20 >> 1),
  1775.     },
  1776. #endif
  1777. #ifdef CONFIG_MT9P012
  1778.     {
  1779.         I2C_BOARD_INFO("mt9p012", 0x6C >> 1),
  1780.     },
  1781. #endif
  1782. #ifdef CONFIG_MT9P012_KM
  1783.     {
  1784.         I2C_BOARD_INFO("mt9p012_km", 0x6C >> 2),
  1785.     },
  1786. #endif
  1787. #if defined(CONFIG_MT9T013) || defined(CONFIG_SENSORS_MT9T013)
  1788.     {
  1789.         I2C_BOARD_INFO("mt9t013", 0x6C),
  1790.     },
  1791. #endif
  1792. #ifdef CONFIG_VB6801
  1793.     {
  1794.         I2C_BOARD_INFO("vb6801", 0x20),
  1795.     },
  1796. #endif
  1797.  
  1798. #ifdef CONFIG_MT9P111
  1799.     /*
  1800.      * Commented by zhang.shengjie
  1801.      *
  1802.      * Refer to drivers/media/video/msm/mt9p111.c
  1803.      * For MT9P111: 5.0Mp, 1/4-Inch System-On-A-Chip (SOC) CMOS Digital Image Sensor
  1804.      *
  1805.      * Attention: I2C device is initialized in sensor's driver if "CONFIG_SENSOR_ADAPTER"
  1806.      *            is defined
  1807.      */
  1808. #if !defined(CONFIG_SENSOR_ADAPTER)
  1809.     {
  1810.         I2C_BOARD_INFO("mt9p111", 0x7A >> 1),
  1811.     },
  1812. #else
  1813.     //Do nothing
  1814. #endif
  1815. #endif
  1816.  
  1817. #ifdef CONFIG_MT9T11X
  1818.     /*
  1819.      * Commented by zhang.shengjie, ZTE_MSM_CAMERA_ZHSHJ_001
  1820.      *
  1821.      * Refer to drivers/media/video/msm/mt9t11x.c
  1822.      * For MT9T111: 3.1Mp, 1/4-Inch System-On-A-Chip (SOC) CMOS Digital Image Sensor
  1823.      * For MT9T112: 3.1Mp, 1/4-Inch System-On-A-Chip (SOC) CMOS Digital Image Sensor
  1824.      *
  1825.      * Attention: I2C device is initialized in sensor's driver if "CONFIG_SENSOR_ADAPTER"
  1826.      *            is defined
  1827.      */
  1828. #if !defined(CONFIG_SENSOR_ADAPTER)
  1829.     {
  1830.         I2C_BOARD_INFO("mt9t11x", 0x7A >> 1),
  1831.     },
  1832. #else
  1833.     //Do nothing
  1834. #endif
  1835. #endif
  1836.  
  1837. #ifdef CONFIG_MT9D115
  1838.  
  1839.  #if !defined(CONFIG_SENSOR_ADAPTER)
  1840.     {
  1841.         I2C_BOARD_INFO("mt9d115", 0x78 >> 1),
  1842.     },
  1843. #else
  1844.     //Do nothing
  1845. #endif
  1846. #endif
  1847.  
  1848. #ifdef CONFIG_MT9V113
  1849.     /*
  1850.      * Commented by zhang.shengjie
  1851.      *
  1852.      * Refer to drivers/media/video/msm/mt9v113.c
  1853.      * For MT9V113: 0.3Mp, 1/11-Inch System-On-A-Chip (SOC) CMOS Digital Image Sensor
  1854.      */
  1855.     {
  1856.         I2C_BOARD_INFO("mt9v113", 0x78 >> 1),
  1857.     },
  1858. #endif
  1859.  
  1860. #ifdef CONFIG_OV5642
  1861.     /*
  1862.      * Commented by zhang.shengjie
  1863.      *
  1864.      * Refer to drivers/media/video/msm/ov5642.c
  1865.      * For OV5642: 5.0Mp, 1/11-Inch System-On-A-Chip (SOC) CMOS Digital Image Sensor
  1866.      *
  1867.      * Attention: I2C device is initialized in sensor's driver if "CONFIG_SENSOR_ADAPTER"
  1868.      *            is defined
  1869.      */
  1870. #if !defined(CONFIG_SENSOR_ADAPTER)
  1871.     {
  1872.         I2C_BOARD_INFO("ov5642", 0x78 >> 1),
  1873.     },
  1874. #else
  1875.     //Do nothing
  1876. #endif
  1877. #endif
  1878.  
  1879.  
  1880. #ifdef CONFIG_OV5640
  1881.  
  1882. #if !defined(CONFIG_SENSOR_ADAPTER)
  1883.     {
  1884.         I2C_BOARD_INFO("ov5640", 0x78 >> 1),
  1885.     },
  1886. #else
  1887.     //Do nothing
  1888. #endif
  1889. #endif
  1890.  
  1891. //ZTE_TSSC_WLY_002,2010-05-10
  1892. #ifdef CONFIG_TOUCHSCREEN_SYNAPTICS_3K
  1893. {
  1894.         I2C_BOARD_INFO(SYNAPTICS_I2C_RMI4_NAME, TS_I2C_ADDR ),
  1895.         .irq = MSM_GPIO_TO_INT(GPIO_TS_IRQ),
  1896.         //.platform_data = touchscreen_power,
  1897.         .platform_data = &synaptics_ts_data,
  1898.     },
  1899. #endif
  1900. #ifdef CONFIG_TOUCHSCREEN_CYPRESS_I2C_RMI
  1901.     {
  1902.         .type         = "cypress_touch",
  1903.         /*.flags        = ,*/
  1904.         .addr         = 0x0a,
  1905.         .irq          = MSM_GPIO_TO_INT(29),
  1906.     },
  1907. #endif
  1908. //ZTE_TSSC_WLY_002,2010-05-10
  1909. //ZTE_TS_ZFJ_20110124 begin
  1910. #ifdef CONFIG_TOUCHSCREEN_FOCALTECH
  1911.     {
  1912.         .type         = "ft5x0x_ts",
  1913.         /*.flags        = ,*/
  1914.         .addr         = 0x3E,//0x38 ZTE_TS_ZFJ_20110125
  1915.         .irq          = MSM_GPIO_TO_INT(29),
  1916.     },
  1917. #endif
  1918. #ifdef CONFIG_TOUCHSCREEN_FOCALTECH_NEW//ZTE_TS_XYM_20110711
  1919.     {
  1920.         .type         = "ft5x0x_ts",
  1921.         /*.flags        = ,*/
  1922.         .addr         = 0x3E,
  1923.         .irq          = MSM_GPIO_TO_INT(29),
  1924.     },
  1925. #endif
  1926. //ZTE_TS_ZFJ_20110412 end
  1927. /*ZTE_TS_ZFJ_20110509 begin*/
  1928. #ifdef CONFIG_TOUCHSCREEN_MXT224
  1929.     {    
  1930.         I2C_BOARD_INFO(ATMEL_QT602240_NAME, 0x4a ),
  1931.         .platform_data = &atmel_data,
  1932.         .irq = MSM_GPIO_TO_INT(29),
  1933.     },  
  1934. #endif
  1935. /*ZTE_TS_ZFJ_20110509 end*/
  1936. //ZTE_TS_XYM_20110715 begin
  1937. #ifdef CONFIG_TOUCHSCREEN_CY8CTST241
  1938.     {    
  1939.         I2C_BOARD_INFO(CY_I2C_NAME, 0x24),
  1940.         .platform_data = &cypress_i2c_ttsp_platform_data,
  1941.     },  
  1942. #endif
  1943. //ZTE_TS_XYM_20110715 end
  1944.  
  1945. };
  1946.  
  1947. /*ZTE_AUX_FYA_001,@2010-02-06,BEGIN*/
  1948. static struct i2c_gpio_platform_data aux_i2c_gpio_data = {
  1949.     .sda_pin        = 93,
  1950.     .scl_pin        = 92,
  1951.     .sda_is_open_drain  = 1,
  1952.     .scl_is_open_drain  = 1,
  1953.     .udelay         = 40,
  1954. };
  1955.  
  1956. static struct platform_device aux_i2c_gpio_device = {
  1957.     .name       = "i2c-gpio",
  1958.     .id     = 1,
  1959.     .dev        = {
  1960.         .platform_data  = &aux_i2c_gpio_data
  1961.     },
  1962. };
  1963. /*ZTE_AUX_FYA_001,@2010-02-06,END*/
  1964.  
  1965. /*ZTE_AUX2_FYA_001,@2010-02-06,BEGIN*/
  1966. static struct i2c_gpio_platform_data aux2_i2c_gpio_data = {
  1967.     .sda_pin        = 109,
  1968.     .scl_pin        = 107,
  1969.     .sda_is_open_drain  = 0,
  1970.     .scl_is_open_drain  = 1,
  1971.     .udelay         = 2,
  1972. };
  1973.  
  1974. static struct platform_device aux2_i2c_gpio_device = {
  1975.     .name       = "i2c-gpio",
  1976.     .id     = 2,
  1977.     .dev        = {
  1978.         .platform_data  = &aux2_i2c_gpio_data
  1979.     },
  1980. };
  1981. /*ZTE_AUX2_FYA_001,@2010-02-06,BEGIN*/
  1982. #ifdef CONFIG_MSM_CAMERA
  1983. static uint32_t camera_off_gpio_table[] = {
  1984.     /* parallel CAMERA interfaces */
  1985.     /*
  1986.      * Commented by zh.shj
  1987.      *
  1988.      * Refer to drivers/media/video/msm/mt9v113.c
  1989.      * For MT9V113: 0.3Mp, 1/11-Inch System-On-A-Chip (SOC) CMOS Digital Image Sensor
  1990.      *
  1991.      * Refer to drivers/media/video/msm/mt9p111.c
  1992.      * For MT9P111: 5.0Mp, 1/4-Inch System-On-A-Chip (SOC) CMOS Digital Image Sensor
  1993.      *
  1994.      * GPIO: 0, 1, 2, and 3 are configured as "CAM30_PWRDN", "CAM500_PWRDN", "CAM500_RST", and "FM_RST"
  1995.      */  
  1996. #if 0
  1997.     GPIO_CFG(0,  0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT0 */
  1998.     GPIO_CFG(1,  0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT1 */
  1999.     GPIO_CFG(2,  0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT2 */
  2000.     GPIO_CFG(3,  0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT3 */
  2001.     GPIO_CFG(4,  0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT4 */
  2002.     GPIO_CFG(5,  0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT5 */
  2003.     GPIO_CFG(6,  0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT6 */
  2004.     GPIO_CFG(7,  0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT7 */
  2005.     GPIO_CFG(8,  0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT8 */
  2006.     GPIO_CFG(9,  0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT9 */
  2007.     GPIO_CFG(10, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT10 */
  2008.     GPIO_CFG(11, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT11 */
  2009.     GPIO_CFG(12, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* PCLK */
  2010.     GPIO_CFG(13, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* HSYNC_IN */
  2011.     GPIO_CFG(14, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* VSYNC_IN */
  2012.     GPIO_CFG(15, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_2MA), /* MCLK */
  2013. #else
  2014.     GPIO_CFG(4,  0, GPIO_OUTPUT, GPIO_PULL_DOWN, GPIO_2MA), /* CIF_DATA <0> */
  2015.     GPIO_CFG(5,  0, GPIO_OUTPUT, GPIO_PULL_DOWN, GPIO_2MA), /* CIF_DATA <1> */
  2016.     GPIO_CFG(6,  0, GPIO_OUTPUT, GPIO_PULL_DOWN, GPIO_2MA), /* CIF_DATA <2> */
  2017.     GPIO_CFG(7,  0, GPIO_OUTPUT, GPIO_PULL_DOWN, GPIO_2MA), /* CIF_DATA <3> */
  2018.     GPIO_CFG(8,  0, GPIO_OUTPUT, GPIO_PULL_DOWN, GPIO_2MA), /* CIF_DATA <4> */
  2019.     GPIO_CFG(9,  0, GPIO_OUTPUT, GPIO_PULL_DOWN, GPIO_2MA), /* CIF_DATA <5> */
  2020.     GPIO_CFG(10, 0, GPIO_OUTPUT, GPIO_PULL_DOWN, GPIO_2MA), /* CIF_DATA <6> */
  2021.     GPIO_CFG(11, 0, GPIO_OUTPUT, GPIO_PULL_DOWN, GPIO_2MA), /* CIF_DATA <7> */
  2022.     GPIO_CFG(12, 0, GPIO_OUTPUT, GPIO_PULL_DOWN, GPIO_2MA), /* CIF_PCLK */
  2023.     GPIO_CFG(13, 0, GPIO_OUTPUT, GPIO_PULL_DOWN, GPIO_2MA), /* CIF_HSYNC */
  2024.     GPIO_CFG(14, 0, GPIO_OUTPUT, GPIO_PULL_DOWN, GPIO_2MA), /* CIF_VSYNC */
  2025.     GPIO_CFG(15, 0, GPIO_OUTPUT, GPIO_PULL_DOWN, GPIO_2MA),  /* CIF_MCLK */
  2026. #endif
  2027. };
  2028.  
  2029. static uint32_t camera_on_gpio_table[] = {
  2030.     /* parallel CAMERA interfaces */
  2031.     /*
  2032.      * Commented by zh.shj
  2033.      *
  2034.      * Refer to drivers/media/video/msm/mt9v113.c
  2035.      * For MT9V113: 0.3Mp, 1/11-Inch System-On-A-Chip (SOC) CMOS Digital Image Sensor
  2036.      *
  2037.      * Refer to drivers/media/video/msm/mt9p111.c
  2038.      * For MT9P111: 5.0Mp, 1/4-Inch System-On-A-Chip (SOC) CMOS Digital Image Sensor
  2039.      *
  2040.      * GPIO: 0, 1, 2, and 3 are configured as "CAM30_PWRDN", "CAM500_PWRDN", "CAM500_RST", and "FM_RST"
  2041.      */  
  2042. #if 0
  2043.     GPIO_CFG(0,  1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT0 */
  2044.     GPIO_CFG(1,  1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT1 */
  2045.     GPIO_CFG(2,  1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT2 */
  2046.     GPIO_CFG(3,  1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT3 */
  2047. #endif
  2048.     GPIO_CFG(4,  1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT4 */
  2049.     GPIO_CFG(5,  1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT5 */
  2050.     GPIO_CFG(6,  1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT6 */
  2051.     GPIO_CFG(7,  1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT7 */
  2052.     GPIO_CFG(8,  1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT8 */
  2053.     GPIO_CFG(9,  1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT9 */
  2054.     GPIO_CFG(10, 1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT10 */
  2055.     GPIO_CFG(11, 1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* DAT11 */
  2056.     GPIO_CFG(12, 1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_16MA), /* PCLK */
  2057.     GPIO_CFG(13, 1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* HSYNC_IN */
  2058.     GPIO_CFG(14, 1, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), /* VSYNC_IN */
  2059.     GPIO_CFG(15, 1, GPIO_OUTPUT, GPIO_PULL_DOWN, GPIO_16MA), /* MCLK */
  2060. };
  2061.  
  2062. static void config_gpio_table(uint32_t *table, int len)
  2063. {
  2064.     int n, rc;
  2065.     for (n = 0; n < len; n++) {
  2066.         rc = gpio_tlmm_config(table[n], GPIO_ENABLE);
  2067.         if (rc) {
  2068.             printk(KERN_ERR "%s: gpio_tlmm_config(%#x)=%d\n",
  2069.                 __func__, table[n], rc);
  2070.             break;
  2071.         }
  2072.     }
  2073. }
  2074.  
  2075. static struct vreg *vreg_gp2;
  2076. static struct vreg *vreg_gp3;
  2077.  
  2078. static void msm_camera_vreg_config(int vreg_en)
  2079. {
  2080.     int rc;
  2081.  
  2082.     if (vreg_gp2 == NULL) {
  2083.         vreg_gp2 = vreg_get(NULL, "gp2");
  2084.         if (IS_ERR(vreg_gp2)) {
  2085.             printk(KERN_ERR "%s: vreg_get(%s) failed (%ld)\n",
  2086.                 __func__, "gp2", PTR_ERR(vreg_gp2));
  2087.             return;
  2088.         }
  2089.  
  2090.         rc = vreg_set_level(vreg_gp2, 1800);
  2091.         if (rc) {
  2092.             printk(KERN_ERR "%s: GP2 set_level failed (%d)\n",
  2093.                 __func__, rc);
  2094.         }
  2095.     }
  2096.  
  2097.     if (vreg_gp3 == NULL) {
  2098.         vreg_gp3 = vreg_get(NULL, "gp3");
  2099.         if (IS_ERR(vreg_gp3)) {
  2100.             printk(KERN_ERR "%s: vreg_get(%s) failed (%ld)\n",
  2101.                 __func__, "gp3", PTR_ERR(vreg_gp3));
  2102.             return;
  2103.         }
  2104.  
  2105.         rc = vreg_set_level(vreg_gp3, 2850);
  2106.         if (rc) {
  2107.             printk(KERN_ERR "%s: GP3 set level failed (%d)\n",
  2108.                 __func__, rc);
  2109.         }
  2110.     }
  2111.  
  2112.     if (vreg_en) {
  2113.         rc = vreg_enable(vreg_gp2);
  2114.         if (rc) {
  2115.             printk(KERN_ERR "%s: GP2 enable failed (%d)\n",
  2116.                  __func__, rc);
  2117.         }
  2118.  
  2119.         rc = vreg_enable(vreg_gp3);
  2120.         if (rc) {
  2121.             printk(KERN_ERR "%s: GP3 enable failed (%d)\n",
  2122.                 __func__, rc);
  2123.         }
  2124.     } else {
  2125.         rc = vreg_disable(vreg_gp2);
  2126.         if (rc) {
  2127.             printk(KERN_ERR "%s: GP2 disable failed (%d)\n",
  2128.                  __func__, rc);
  2129.         }
  2130.  
  2131.         rc = vreg_disable(vreg_gp3);
  2132.         if (rc) {
  2133.             printk(KERN_ERR "%s: GP3 disable failed (%d)\n",
  2134.                 __func__, rc);
  2135.         }
  2136.     }
  2137. }
  2138.  
  2139. static void config_camera_on_gpios(void)
  2140. {
  2141.     int vreg_en = 1;
  2142.  
  2143.     if (machine_is_msm7x25_ffa() ||
  2144.         machine_is_msm7x27_ffa())
  2145.         msm_camera_vreg_config(vreg_en);
  2146.  
  2147.     config_gpio_table(camera_on_gpio_table,
  2148.         ARRAY_SIZE(camera_on_gpio_table));
  2149.     //return 0;
  2150. }
  2151.  
  2152. static void config_camera_off_gpios(void)
  2153. {
  2154.     int vreg_en = 0;
  2155.  
  2156.     if (machine_is_msm7x25_ffa() ||
  2157.         machine_is_msm7x27_ffa())
  2158.         msm_camera_vreg_config(vreg_en);
  2159.  
  2160.     config_gpio_table(camera_off_gpio_table,
  2161.         ARRAY_SIZE(camera_off_gpio_table));
  2162. }
  2163.  
  2164. /*
  2165.  * Commented by zh.shj, ZTE_MSM_CAMERA_ZHSHJ_001
  2166.  *
  2167.  * Camera power setting for backend sensor, i.e., MT9T111/MT9T112/OV5642/ov5640
  2168.  * For MT9T111: 3.1Mp, 1/4-Inch System-On-A-Chip (SOC) CMOS Digital Image Sensor
  2169.  * For MT9T112: 3.1Mp, 1/4-Inch System-On-A-Chip (SOC) CMOS Digital Image Sensor
  2170.  */
  2171. #define MSM_CAMERA_POWER_BACKEND_DVDD_VAL       (1800)
  2172. #define MSM_CAMERA_POWER_BACKEND_IOVDD_VAL      (2600)
  2173. #define MSM_CAMERA_POWER_BACKEND_AVDD_VAL       (2800)
  2174. int32_t msm_camera_power_backend(enum msm_camera_pwr_mode_t pwr_mode)
  2175. {
  2176.     struct vreg *vreg_cam_dvdd  = NULL;
  2177.     struct vreg *vreg_cam_avdd  = NULL;
  2178.     struct vreg *vreg_cam_iovdd = NULL;
  2179.     int32_t rc_cam_dvdd, rc_cam_avdd, rc_cam_iovdd;
  2180.  
  2181.     CDBG("%s: entry\n", __func__);
  2182.  
  2183.     /*
  2184.       * Power-up Sequence according to datasheet of sensor:
  2185.       *
  2186.       * VREG_CAM_DVDD1V8  = VREG_GP2
  2187.       * VREG_CAM_IOVDD2V8 = VREG_MSMP
  2188.       * VREG_CAM_AVDD2V6  = VREG_GP3
  2189.       */
  2190.     vreg_cam_dvdd  = vreg_get(0, "gp2");
  2191.     vreg_cam_iovdd = vreg_get(0, "msmp");
  2192.     vreg_cam_avdd  = vreg_get(0, "gp3");
  2193.     if ((!vreg_cam_dvdd) || (!vreg_cam_iovdd) || (!vreg_cam_avdd))
  2194.     {
  2195.         CCRT("%s: vreg_get failed!\n", __func__);
  2196.         return -EIO;
  2197.     }
  2198.  
  2199.     switch (pwr_mode)
  2200.     {
  2201.         case MSM_CAMERA_PWRUP_MODE:
  2202.         {
  2203.             /* DVDD for both 5.0Mp and 3.0Mp camera on board-blade */
  2204.             rc_cam_dvdd = vreg_set_level(vreg_cam_dvdd, MSM_CAMERA_POWER_BACKEND_DVDD_VAL);
  2205.             if (rc_cam_dvdd)
  2206.             {
  2207.                 CCRT("%s: vreg_set_level failed!\n", __func__);
  2208.                 return -EIO;
  2209.             }
  2210.  
  2211.             rc_cam_dvdd = vreg_enable(vreg_cam_dvdd);
  2212.             if (rc_cam_dvdd)
  2213.             {
  2214.                 CCRT("%s: vreg_enable failed!\n", __func__);
  2215.                 return -EIO;
  2216.             }
  2217.  
  2218.             mdelay(1);
  2219.  
  2220.             rc_cam_iovdd = vreg_set_level(vreg_cam_iovdd, MSM_CAMERA_POWER_BACKEND_IOVDD_VAL);
  2221.             if (rc_cam_iovdd)
  2222.             {
  2223.                 CCRT("%s: vreg_set_level failed!\n", __func__);
  2224.                 return -EIO;
  2225.             }
  2226.  
  2227.             rc_cam_iovdd = vreg_enable(vreg_cam_iovdd);
  2228.             if (rc_cam_iovdd)
  2229.             {
  2230.                 CCRT("%s: vreg_enable failed!\n", __func__);
  2231.                 return -EIO;
  2232.             }
  2233.  
  2234.             mdelay(2);
  2235.  
  2236.             /*
  2237.                * AVDD for both 5.0Mp and 3.0Mp camera on board-blade
  2238.                * AVDD and VCM are connected together on board-blade
  2239.                */
  2240.             rc_cam_avdd = vreg_set_level(vreg_cam_avdd, MSM_CAMERA_POWER_BACKEND_AVDD_VAL);
  2241.             if (rc_cam_avdd)
  2242.             {
  2243.                 CCRT("%s: vreg_set_level failed!\n", __func__);
  2244.                 return -EIO;
  2245.             }
  2246.  
  2247.             rc_cam_avdd = vreg_enable(vreg_cam_avdd);
  2248.             if (rc_cam_avdd)
  2249.             {
  2250.                 CCRT("%s: vreg_enable failed!\n", __func__);
  2251.                 return -EIO;
  2252.             }
  2253.  
  2254.             mdelay(500);
  2255.  
  2256.             break;
  2257.         }
  2258.         case MSM_CAMERA_STANDBY_MODE:
  2259.         {
  2260.             rc_cam_avdd  = vreg_disable(vreg_cam_avdd);
  2261.             if (rc_cam_avdd)
  2262.             {
  2263.                 CCRT("%s: vreg_disable failed!\n", __func__);
  2264.                 return -EIO;
  2265.             }
  2266.  
  2267.             break;
  2268.         }
  2269.         case MSM_CAMERA_NORMAL_MODE:
  2270.         {
  2271.             /*
  2272.                * AVDD and VCM are connected together on board-blade
  2273.                */
  2274.             rc_cam_avdd = vreg_set_level(vreg_cam_avdd, MSM_CAMERA_POWER_BACKEND_AVDD_VAL);
  2275.             if (rc_cam_avdd)
  2276.             {
  2277.                 CCRT("%s: vreg_set_level failed!\n", __func__);
  2278.                 return -EIO;
  2279.             }
  2280.  
  2281.             rc_cam_avdd = vreg_enable(vreg_cam_avdd);
  2282.             if (rc_cam_avdd)
  2283.             {
  2284.                 CCRT("%s: vreg_enable failed!\n", __func__);
  2285.                 return -EIO;
  2286.             }
  2287.  
  2288.             mdelay(100);
  2289.  
  2290.             break;
  2291.         }
  2292.         case MSM_CAMERA_PWRDWN_MODE:
  2293.         {
  2294.             /*
  2295.                * Attention: DVDD, AVDD, or MOTORVDD may be used by other devices
  2296.                */
  2297.             rc_cam_dvdd  = vreg_disable(vreg_cam_dvdd);
  2298.             rc_cam_avdd  = vreg_disable(vreg_cam_avdd);
  2299.             if ((rc_cam_dvdd) || (rc_cam_avdd))
  2300.             {
  2301.                 CCRT("%s: vreg_disable failed!\n", __func__);
  2302.                 return -EIO;
  2303.             }
  2304.  
  2305.             break;
  2306.         }
  2307.         default:
  2308.         {
  2309.             CCRT("%s: parameter not supported!\n", __func__);
  2310.             return -EIO;
  2311.         }
  2312.     }
  2313.  
  2314.     return 0;
  2315. }
  2316.  
  2317. /*
  2318.  * Commented by zh.shj
  2319.  *
  2320.  * Camera power setting for frontend sensor, i.e., MT9V113
  2321.  * For MT9V113: 0.3Mp, 1/11-Inch System-On-A-Chip (SOC) CMOS Digital Image Sensor
  2322.  */
  2323. #define MSM_CAMERA_POWER_FRONTEND_DVDD_VAL       (1800)
  2324. #define MSM_CAMERA_POWER_FRONTEND_IOVDD_VAL      (2800)
  2325. #define MSM_CAMERA_POWER_FRONTEND_AVDD_VAL       (2600)
  2326. int32_t msm_camera_power_frontend(enum msm_camera_pwr_mode_t pwr_mode)
  2327. {
  2328.     struct vreg *vreg_cam_dvdd  = NULL;
  2329.     struct vreg *vreg_cam_avdd  = NULL;
  2330.     struct vreg *vreg_cam_iovdd = NULL;
  2331.     int32_t rc_cam_dvdd, rc_cam_avdd, rc_cam_iovdd;
  2332.  
  2333.     CDBG("%s: entry\n", __func__);
  2334.  
  2335.     /*
  2336.       * Power-up Sequence according to datasheet of sensor:
  2337.       *
  2338.       * VREG_CAM_DVDD1V8 = VREG_GP2
  2339.       * VREG_CAM30_2V8   = VREG_GP4
  2340.       * VREG_CAM_AVDD2V6 = VREG_GP3
  2341.       */
  2342.     vreg_cam_dvdd  = vreg_get(0, "gp2");
  2343.     vreg_cam_iovdd = vreg_get(0, "gp4");
  2344.     vreg_cam_avdd  = vreg_get(0, "gp3");
  2345.     if ((!vreg_cam_dvdd) || (!vreg_cam_iovdd) || (!vreg_cam_avdd))
  2346.     {
  2347.         CCRT("%s: vreg_get failed!\n", __func__);
  2348.         return -EIO;
  2349.     }
  2350.  
  2351.     switch (pwr_mode)
  2352.     {
  2353.         case MSM_CAMERA_PWRUP_MODE:
  2354.         {
  2355.             rc_cam_dvdd = vreg_set_level(vreg_cam_dvdd, MSM_CAMERA_POWER_FRONTEND_DVDD_VAL);
  2356.             if (rc_cam_dvdd)
  2357.             {
  2358.                 CCRT("%s: vreg_set_level failed!\n", __func__);
  2359.                 return -EIO;
  2360.             }
  2361.  
  2362.             rc_cam_dvdd = vreg_enable(vreg_cam_dvdd);
  2363.             if (rc_cam_dvdd)
  2364.             {
  2365.                 CCRT("%s: vreg_enable failed!\n", __func__);
  2366.                 return -EIO;
  2367.             }
  2368.  
  2369.             mdelay(1);
  2370.  
  2371.             rc_cam_iovdd = vreg_set_level(vreg_cam_iovdd, MSM_CAMERA_POWER_FRONTEND_IOVDD_VAL);
  2372.             if (rc_cam_iovdd)
  2373.             {
  2374.                 CCRT("%s: vreg_set_level failed!\n", __func__);
  2375.                 return -EIO;
  2376.             }
  2377.  
  2378.             rc_cam_iovdd = vreg_enable(vreg_cam_iovdd);
  2379.             if (rc_cam_iovdd)
  2380.             {
  2381.                 CCRT("%s: vreg_enable failed!\n", __func__);
  2382.                 return -EIO;
  2383.             }
  2384.  
  2385.             mdelay(2);
  2386.  
  2387.             rc_cam_avdd = vreg_set_level(vreg_cam_avdd, MSM_CAMERA_POWER_FRONTEND_AVDD_VAL);
  2388.             if (rc_cam_avdd)
  2389.             {
  2390.                 CCRT("%s: vreg_set_level failed!\n", __func__);
  2391.                 return -EIO;
  2392.             }
  2393.  
  2394.             rc_cam_avdd = vreg_enable(vreg_cam_avdd);
  2395.             if (rc_cam_avdd)
  2396.             {
  2397.                 CCRT("%s: vreg_enable failed!\n", __func__);
  2398.                 return -EIO;
  2399.             }
  2400.  
  2401.             mdelay(500);
  2402.  
  2403.             break;
  2404.         }
  2405.         case MSM_CAMERA_STANDBY_MODE:
  2406.         {
  2407.             CCRT("%s: MSM_CAMERA_STANDBY_MODE not supported!\n", __func__);
  2408.             return -EIO;
  2409.         }
  2410.         case MSM_CAMERA_NORMAL_MODE:
  2411.         {
  2412.             CCRT("%s: MSM_CAMERA_NORMAL_MODE not supported!\n", __func__);
  2413.             return -EIO;
  2414.         }
  2415.         case MSM_CAMERA_PWRDWN_MODE:
  2416.         {
  2417.             rc_cam_dvdd  = vreg_disable(vreg_cam_dvdd);
  2418.             rc_cam_iovdd = vreg_disable(vreg_cam_iovdd);
  2419.             rc_cam_avdd  = vreg_disable(vreg_cam_avdd);
  2420.             if ((rc_cam_dvdd) || (rc_cam_iovdd) || (rc_cam_avdd))
  2421.             {
  2422.                 CCRT("%s: vreg_disable failed!\n", __func__);
  2423.                 return -EIO;
  2424.             }
  2425.  
  2426.             break;
  2427.         }
  2428.         default:
  2429.         {
  2430.             CCRT("%s: parameter not supported!\n", __func__);
  2431.             return -EIO;
  2432.         }
  2433.     }
  2434.  
  2435.     return 0;
  2436. }
  2437.  
  2438. /*
  2439.  * Commented by zh.shj
  2440.  *
  2441.  * Camera clock switch for both frontend and backend sensors, i.e., MT9V113 and MT9P111
  2442.  *
  2443.  * For MT9V113: 0.3Mp, 1/11-Inch System-On-A-Chip (SOC) CMOS Digital Image Sensor
  2444.  * For MT9P111: 5.0Mp, 1/4-Inch System-On-A-Chip (SOC) CMOS Digital Image Sensor
  2445.  *
  2446.  * switch_val: 0, to switch clock to frontend sensor, i.e., MT9V113, or
  2447.  *             1, to switch clock to backend sensor, i.e., MT9P111
  2448.  */
  2449. int msm_camera_clk_switch(const struct msm_camera_sensor_info *data,
  2450.                                   uint32_t gpio_switch,
  2451.                                   uint32_t switch_val)
  2452. {
  2453.     int rc;
  2454.  
  2455.     CDBG("%s: entry\n", __func__);
  2456.  
  2457.     rc = gpio_request(gpio_switch, data->sensor_name);
  2458.     if (0 == rc)
  2459.     {
  2460.         /* ignore "rc" */
  2461.         rc = gpio_direction_output(gpio_switch, switch_val);
  2462.  
  2463.         /* time delay */
  2464.         mdelay(1);
  2465.     }
  2466.  
  2467.     gpio_free(gpio_switch);
  2468.  
  2469.     return rc;
  2470. }
  2471.  
  2472. static struct msm_camera_device_platform_data msm_camera_device_data = {
  2473.     .camera_gpio_on  = config_camera_on_gpios,
  2474.     .camera_gpio_off = config_camera_off_gpios,
  2475.     .ioext.mdcphy = MSM_MDC_PHYS,
  2476.     .ioext.mdcsz  = MSM_MDC_SIZE,
  2477.     .ioext.appphy = MSM_CLK_CTL_PHYS,
  2478.     .ioext.appsz  = MSM_CLK_CTL_SIZE,
  2479. };
  2480.  
  2481. static struct msm_camera_sensor_flash_src msm_flash_src = {
  2482.     .flash_sr_type = MSM_CAMERA_FLASH_SRC_PMIC,
  2483.     ._fsrc.pmic_src.low_current  = 30,
  2484.     ._fsrc.pmic_src.high_current = 100,
  2485. };
  2486.  
  2487. #ifdef CONFIG_MT9D112
  2488. static struct msm_camera_sensor_flash_data flash_mt9d112 = {
  2489.     .flash_type = MSM_CAMERA_FLASH_LED,
  2490.     .flash_src  = &msm_flash_src
  2491. };
  2492.  
  2493. static struct msm_camera_sensor_info msm_camera_sensor_mt9d112_data = {
  2494.     .sensor_name    = "mt9d112",
  2495.     .sensor_reset   = 89,
  2496.     .sensor_pwd     = 85,
  2497.     .vcm_pwd        = 0,
  2498.     .vcm_enable     = 0,
  2499.     .pdata          = &msm_camera_device_data,
  2500.     .flash_data     = &flash_mt9d112
  2501. };
  2502.  
  2503. static struct platform_device msm_camera_sensor_mt9d112 = {
  2504.     .name      = "msm_camera_mt9d112",
  2505.     .dev       = {
  2506.         .platform_data = &msm_camera_sensor_mt9d112_data,
  2507.     },
  2508. };
  2509. #endif
  2510.  
  2511. #ifdef CONFIG_S5K3E2FX
  2512. static struct msm_camera_sensor_flash_data flash_s5k3e2fx = {
  2513.     .flash_type = MSM_CAMERA_FLASH_LED,
  2514.     .flash_src  = &msm_flash_src
  2515. };
  2516.  
  2517. static struct msm_camera_sensor_info msm_camera_sensor_s5k3e2fx_data = {
  2518.     .sensor_name    = "s5k3e2fx",
  2519.     .sensor_reset   = 89,
  2520.     .sensor_pwd     = 85,
  2521.     .vcm_pwd        = 0,
  2522.     .vcm_enable     = 0,
  2523.     .pdata          = &msm_camera_device_data,
  2524.     .flash_data     = &flash_s5k3e2fx
  2525. };
  2526.  
  2527. static struct platform_device msm_camera_sensor_s5k3e2fx = {
  2528.     .name      = "msm_camera_s5k3e2fx",
  2529.     .dev       = {
  2530.         .platform_data = &msm_camera_sensor_s5k3e2fx_data,
  2531.     },
  2532. };
  2533. #endif
  2534.  
  2535. #ifdef CONFIG_MT9P012
  2536. static struct msm_camera_sensor_flash_data flash_mt9p012 = {
  2537.     .flash_type = MSM_CAMERA_FLASH_LED,
  2538.     .flash_src  = &msm_flash_src
  2539. };
  2540.  
  2541. static struct msm_camera_sensor_info msm_camera_sensor_mt9p012_data = {
  2542.     .sensor_name    = "mt9p012",
  2543.     .sensor_reset   = 89,
  2544.     .sensor_pwd     = 85,
  2545.     .vcm_pwd        = 88,
  2546.     .vcm_enable     = 0,
  2547.     .pdata          = &msm_camera_device_data,
  2548.     .flash_data     = &flash_mt9p012
  2549. };
  2550.  
  2551. static struct platform_device msm_camera_sensor_mt9p012 = {
  2552.     .name      = "msm_camera_mt9p012",
  2553.     .dev       = {
  2554.         .platform_data = &msm_camera_sensor_mt9p012_data,
  2555.     },
  2556. };
  2557. #endif
  2558.  
  2559. #ifdef CONFIG_MT9P012_KM
  2560. static struct msm_camera_sensor_flash_data flash_mt9p012_km = {
  2561.     .flash_type = MSM_CAMERA_FLASH_LED,
  2562.     .flash_src  = &msm_flash_src
  2563. };
  2564.  
  2565. static struct msm_camera_sensor_info msm_camera_sensor_mt9p012_km_data = {
  2566.     .sensor_name    = "mt9p012_km",
  2567.     .sensor_reset   = 89,
  2568.     .sensor_pwd     = 85,
  2569.     .vcm_pwd        = 88,
  2570.     .vcm_enable     = 0,
  2571.     .pdata          = &msm_camera_device_data,
  2572.     .flash_data     = &flash_mt9p012_km
  2573. };
  2574.  
  2575. static struct platform_device msm_camera_sensor_mt9p012_km = {
  2576.     .name      = "msm_camera_mt9p012_km",
  2577.     .dev       = {
  2578.         .platform_data = &msm_camera_sensor_mt9p012_km_data,
  2579.     },
  2580. };
  2581. #endif
  2582.  
  2583. #ifdef CONFIG_MT9T013
  2584. static struct msm_camera_sensor_flash_data flash_mt9t013 = {
  2585.     .flash_type = MSM_CAMERA_FLASH_LED,
  2586.     .flash_src  = &msm_flash_src
  2587. };
  2588.  
  2589. static struct msm_camera_sensor_info msm_camera_sensor_mt9t013_data = {
  2590.     .sensor_name    = "mt9t013",
  2591.     .sensor_reset   = 89,
  2592.     .sensor_pwd     = 85,
  2593.     .vcm_pwd        = 0,
  2594.     .vcm_enable     = 0,
  2595.     .pdata          = &msm_camera_device_data,
  2596.     .flash_data     = &flash_mt9t013
  2597. };
  2598.  
  2599. static struct platform_device msm_camera_sensor_mt9t013 = {
  2600.     .name      = "msm_camera_mt9t013",
  2601.     .dev       = {
  2602.         .platform_data = &msm_camera_sensor_mt9t013_data,
  2603.     },
  2604. };
  2605. #endif
  2606.  
  2607. #ifdef CONFIG_VB6801
  2608. static struct msm_camera_sensor_flash_data flash_vb6801 = {
  2609.     .flash_type = MSM_CAMERA_FLASH_LED,
  2610.     .flash_src  = &msm_flash_src
  2611. };
  2612.  
  2613. static struct msm_camera_sensor_info msm_camera_sensor_vb6801_data = {
  2614.     .sensor_name    = "vb6801",
  2615.     .sensor_reset   = 89,
  2616.     .sensor_pwd     = 88,
  2617.     .vcm_pwd        = 0,
  2618.     .vcm_enable     = 0,
  2619.     .pdata          = &msm_camera_device_data,
  2620.     .flash_data     = &flash_vb6801
  2621. };
  2622.  
  2623. static struct platform_device msm_camera_sensor_vb6801 = {
  2624.     .name      = "msm_camera_vb6801",
  2625.     .dev       = {
  2626.         .platform_data = &msm_camera_sensor_vb6801_data,
  2627.     },
  2628. };
  2629. #endif
  2630. #ifdef CONFIG_MT9P111
  2631. /*
  2632.  * Commented by zhang.shengjie
  2633.  *
  2634.  * Refer to drivers/media/video/msm/mt9p111.c
  2635.  * For MT9P111: 5.0Mp, 1/4-Inch System-On-A-Chip (SOC) CMOS Digital Image Sensor
  2636.  *
  2637.  * ".vcm_pwd" are DISUSED
  2638.  */
  2639.  
  2640. /* CHG_CAM_20100401
  2641.  * Commented by chg
  2642.  * merge 5320 for camera flash.
  2643.  */
  2644. static struct msm_camera_sensor_flash_data flash_mt9p111 = {
  2645.     .flash_type = MSM_CAMERA_FLASH_NONE,
  2646.     .flash_src  = &msm_flash_src
  2647. };
  2648.  
  2649. static struct msm_camera_sensor_info msm_camera_sensor_mt9p111_data = {
  2650.     .sensor_name    = "mt9p111",
  2651.     .sensor_reset   = 2,
  2652.     .sensor_pwd     = 1,
  2653.     .vcm_pwd        = 0,
  2654.     .vcm_enable     = 0,
  2655.     .pdata          = &msm_camera_device_data,
  2656.     .flash_data     = &flash_mt9p111
  2657. };
  2658.  
  2659. static struct platform_device msm_camera_sensor_mt9p111 = {
  2660.     .name      = "msm_camera_mt9p111",
  2661.     .dev       = {
  2662.         .platform_data = &msm_camera_sensor_mt9p111_data,
  2663.     },
  2664. };
  2665. #endif
  2666.  
  2667. #ifdef CONFIG_MT9T11X
  2668. /*
  2669.  * Commented by zhang.shengjie, ZTE_MSM_CAMERA_ZHSHJ_001
  2670.  *
  2671.  * Refer to drivers/media/video/msm/mt9t11x.c
  2672.  * For MT9T111: 3.1Mp, 1/4-Inch System-On-A-Chip (SOC) CMOS Digital Image Sensor
  2673.  * For MT9T112: 3.1Mp, 1/4-Inch System-On-A-Chip (SOC) CMOS Digital Image Sensor
  2674.  *
  2675.  * ".vcm_pwd" are DISUSED
  2676.  */
  2677.  
  2678. /* CHG_CAM_20100401
  2679.  * Commented by chg
  2680.  * merge 5320 for camera flash.
  2681.  */
  2682. static struct msm_camera_sensor_flash_data flash_mt9t11x = {
  2683.     .flash_type = MSM_CAMERA_FLASH_NONE,
  2684.     .flash_src  = &msm_flash_src
  2685. };
  2686.  
  2687. static struct msm_camera_sensor_info msm_camera_sensor_mt9t11x_data = {
  2688.     .sensor_name    = "mt9t11x",
  2689.     .sensor_reset   = 2,
  2690.     .sensor_pwd     = 1,
  2691.     .vcm_pwd        = 0,
  2692.     .vcm_enable     = 0,
  2693.     .pdata          = &msm_camera_device_data,
  2694.     .flash_data     = &flash_mt9t11x
  2695. };
  2696.  
  2697. static struct platform_device msm_camera_sensor_mt9t11x = {
  2698.     .name      = "msm_camera_mt9t11x",
  2699.     .dev       = {
  2700.         .platform_data = &msm_camera_sensor_mt9t11x_data,
  2701.     },
  2702. };
  2703. #endif
  2704.  
  2705. #ifdef CONFIG_MT9D115
  2706. /*
  2707.  * add by ZTE_CAMERA_LIJING_20100629 for MT9D115-2.0Mp-FF-Socket
  2708.  */
  2709. static struct msm_camera_sensor_flash_data flash_mt9d115 = {
  2710.     .flash_type = MSM_CAMERA_FLASH_NONE,
  2711.     .flash_src  = &msm_flash_src
  2712. };
  2713.  
  2714. static struct msm_camera_sensor_info msm_camera_sensor_mt9d115_data = {
  2715.     .sensor_name    = "mt9d115",
  2716.     .sensor_reset   = 2,
  2717.     .sensor_pwd     = 1,
  2718.     .vcm_pwd        = 0,
  2719.     .vcm_enable     = 0,
  2720.     .pdata          = &msm_camera_device_data,
  2721.     .flash_data     = &flash_mt9d115
  2722. };
  2723.  
  2724. static struct platform_device msm_camera_sensor_mt9d115 = {
  2725.     .name      = "msm_camera_mt9d115",
  2726.     .dev       = {
  2727.         .platform_data = &msm_camera_sensor_mt9d115_data,
  2728.     },
  2729. };
  2730. #endif
  2731.  
  2732. #ifdef CONFIG_MT9V113
  2733. /*
  2734.  * Commented by zhang.shengjie
  2735.  *
  2736.  * Refer to drivers/media/video/msm/mt9v113.c
  2737.  * For MT9V113: 0.3Mp, 1/11-Inch System-On-A-Chip (SOC) CMOS Digital Image Sensor
  2738.  */
  2739.  
  2740. /* CHG_CAM_20100401
  2741.  * Commented by chg
  2742.  * merge 5320 for camera flash.
  2743.  */
  2744. static struct msm_camera_sensor_flash_data flash_mt9v113 = {
  2745.     .flash_type = MSM_CAMERA_FLASH_NONE,
  2746.     .flash_src  = &msm_flash_src
  2747. };
  2748.  
  2749. static struct msm_camera_sensor_info msm_camera_sensor_mt9v113_data = {
  2750.     .sensor_name    = "mt9v113",
  2751.     .sensor_reset   = 0,
  2752.     .sensor_pwd     = 0,
  2753.     .vcm_pwd        = 0,
  2754.     .vcm_enable     = 0,
  2755.     .pdata          = &msm_camera_device_data,
  2756.     .flash_data     = &flash_mt9v113
  2757. };
  2758.  
  2759. static struct platform_device msm_camera_sensor_mt9v113 = {
  2760.     .name      = "msm_camera_mt9v113",
  2761.     .dev       = {
  2762.         .platform_data = &msm_camera_sensor_mt9v113_data,
  2763.     },
  2764. };
  2765. #endif
  2766.  
  2767. #ifdef CONFIG_OV5642
  2768. /*
  2769.  * Commented by zhang.shengjie
  2770.  *
  2771.  * Refer to drivers/media/video/msm/ov5642.c
  2772.  * For OV5642: 5.0Mp, 1/4-Inch System-On-A-Chip (SOC) CMOS Digital Image Sensor
  2773.  *
  2774.  * ".vcm_pwd" are DISUSED
  2775.  */
  2776.  
  2777. /* CHG_CAM_20100401
  2778.  * Commented by chg
  2779.  * merge 5320 for camera flash.
  2780.  */
  2781. static struct msm_camera_sensor_flash_data flash_ov5642 = {
  2782.     .flash_type = MSM_CAMERA_FLASH_NONE,
  2783.     .flash_src  = &msm_flash_src
  2784. };
  2785.  
  2786. static struct msm_camera_sensor_info msm_camera_sensor_ov5642_data = {
  2787.     .sensor_name    = "ov5642",
  2788.     .sensor_reset   = 2,
  2789.     .sensor_pwd     = 1,
  2790.     .vcm_pwd        = 0,
  2791.     .vcm_enable     = 0,
  2792.     .pdata          = &msm_camera_device_data,
  2793.     .flash_data     = &flash_ov5642
  2794. };
  2795.  
  2796. static struct platform_device msm_camera_sensor_ov5642 = {
  2797.     .name      = "msm_camera_ov5642",
  2798.     .dev       = {
  2799.         .platform_data = &msm_camera_sensor_ov5642_data,
  2800.     },
  2801. };
  2802. #endif
  2803.  
  2804. #ifdef CONFIG_OV5640
  2805.  
  2806.  
  2807.  
  2808. static struct msm_camera_sensor_flash_data flash_ov5640 = {
  2809.     .flash_type = MSM_CAMERA_FLASH_NONE,
  2810.     .flash_src  = &msm_flash_src
  2811. };
  2812.  
  2813. static struct msm_camera_sensor_info msm_camera_sensor_ov5640_data = {
  2814.     .sensor_name    = "ov5640",
  2815.     .sensor_reset   = 2,
  2816.     .sensor_pwd     = 1,
  2817.     .vcm_pwd        = 0,
  2818.     .vcm_enable     = 0,
  2819.     .pdata          = &msm_camera_device_data,
  2820.     .flash_data     = &flash_ov5640
  2821. };
  2822.  
  2823. static struct platform_device msm_camera_sensor_ov5640 = {
  2824.     .name      = "msm_camera_ov5640",
  2825.     .dev       = {
  2826.         .platform_data = &msm_camera_sensor_ov5640_data,
  2827.     },
  2828. };
  2829. #endif
  2830.  
  2831.  
  2832. #endif
  2833.  
  2834. /*ZTE_TSSC_ZT_004,@2010-01-27,BEGIN*/
  2835. /*ZTE_TSSC_WLY_001, @2010-04-13,BEGIN*/
  2836. /*add touchsreen size definition for mooncake.  QVGA*/
  2837. #if defined( CONFIG_TOUCHSCREEN_MSM_LEGACY)
  2838. struct msm_ts_platform_data msm_tssc_pdata ={
  2839.     .x_max = 239,
  2840.     .y_max = 319,
  2841.     .pressure_max =255,
  2842. };
  2843. #elif defined( CONFIG_TOUCHSCREEN_MSM)
  2844. struct msm_ts_platform_data msm_tssc_pdata = {
  2845.     .min_x = 0,
  2846.     .max_x = 239,
  2847.     .min_y = 0,
  2848.     .max_y = 319,
  2849.     .min_press =0,
  2850.     .max_press =255,
  2851.     .inv_y = 955,
  2852. };
  2853. #endif
  2854. /*ZTE_TSSC_WLY_001, @2010-04-13,END*/
  2855. /*ZTE_TSSC_ZT_004,@2010-01-27,END*/
  2856.  
  2857.  
  2858. #if 0
  2859. static u32 msm_calculate_batt_capacity(u32 current_voltage);
  2860.  
  2861. static struct msm_psy_batt_pdata msm_psy_batt_data = {
  2862.     .voltage_min_design     = 2800,
  2863.     .voltage_max_design = 4300,
  2864.     .avail_chg_sources      = AC_CHG | USB_CHG ,
  2865.     .batt_technology        = POWER_SUPPLY_TECHNOLOGY_LION,
  2866.     .calculate_capacity = &msm_calculate_batt_capacity,
  2867. };
  2868.  
  2869. static u32 msm_calculate_batt_capacity(u32 current_voltage)
  2870. {
  2871.     u32 low_voltage   = msm_psy_batt_data.voltage_min_design;
  2872.     u32 high_voltage  = msm_psy_batt_data.voltage_max_design;
  2873.  
  2874.     return (current_voltage - low_voltage) * 100
  2875.         / (high_voltage - low_voltage);
  2876. }
  2877.  
  2878. static struct platform_device msm_batt_device = {
  2879.     .name           = "msm-battery",
  2880.     .id         = -1,
  2881.     .dev.platform_data  = &msm_psy_batt_data,
  2882. };
  2883. #else
  2884. static u32 msm_calculate_batt_capacity(u32 current_voltage);
  2885.  
  2886. typedef struct
  2887. {
  2888.     u32 voltage;
  2889.     u32 capacity;
  2890. } BattFuelCapacity;
  2891.  
  2892. static const BattFuelCapacity fuelCapacity[] = {
  2893.    {3388, 0},                      /*   0% */
  2894.    {3500, 10},                     /*  10%,3580 is 15% when 3660 is 20 */
  2895.    {3660, 20},                     /*  20% */
  2896.    {3710, 30},                     /*  30% */
  2897.    {3761, 40},                     /*  40% */
  2898.    {3801, 50},                     /*  50% */
  2899.    {3842, 60},                     /*  60% */
  2900.    {3909, 70},                     /*  70% */
  2901.    {3977, 80},                     /*  80% */
  2902.    {4066, 90},                     /*  90% */
  2903.    {4150, 100}                     /* 100% */
  2904. };
  2905.  
  2906. static struct msm_psy_batt_pdata msm_psy_batt_data = {
  2907.     .voltage_min_design     = 2800,
  2908.     .voltage_max_design = 4300,
  2909.     .avail_chg_sources      = AC_CHG | USB_CHG ,
  2910.     .batt_technology        = POWER_SUPPLY_TECHNOLOGY_LION,
  2911.     .calculate_capacity = &msm_calculate_batt_capacity,
  2912. };
  2913.  
  2914. static u32 msm_calculate_batt_capacity(u32 current_voltage)
  2915. {
  2916.     u8 step = sizeof(fuelCapacity)/sizeof(BattFuelCapacity);
  2917.     u8 table_count;
  2918.  
  2919.     if (current_voltage <= fuelCapacity[0].voltage)
  2920.     {
  2921.         return 0;
  2922.     }
  2923.     else if (current_voltage >= fuelCapacity[step-1].voltage)
  2924.     {
  2925.         return 100;
  2926.     }
  2927.     else
  2928.     {    
  2929.         for (table_count = 1; table_count< step; table_count++)
  2930.         {
  2931.             if (current_voltage <= fuelCapacity[table_count].voltage)
  2932.             {
  2933.                 return (fuelCapacity[table_count-1].capacity
  2934.                     + ((current_voltage - fuelCapacity[table_count-1].voltage)*10
  2935.                     /(fuelCapacity[table_count].voltage -
  2936.                     fuelCapacity[table_count-1].voltage)));
  2937.             }
  2938.         }
  2939.     }
  2940.  
  2941.     printk("%s: error\n", __func__);
  2942.     return 0;
  2943. }
  2944.  
  2945. static struct platform_device msm_batt_device = {
  2946.     .name           = "msm-battery",
  2947.     .id         = -1,
  2948.     .dev.platform_data  = &msm_psy_batt_data,
  2949. };
  2950.  
  2951. #endif
  2952.  
  2953. #ifdef CONFIG_ANDROID_RAM_CONSOLE
  2954. static struct resource ram_console_resource[] = {
  2955.     {
  2956.         .start  = MSM_RAM_CONSOLE_PHYS,
  2957.         .end    = MSM_RAM_CONSOLE_PHYS + MSM_RAM_CONSOLE_SIZE - 1,
  2958.         .flags  = IORESOURCE_MEM,
  2959.     },
  2960. };
  2961.  
  2962. static struct platform_device ram_console_device = {
  2963.     .name = "ram_console",
  2964.     .id = -1,
  2965.     .num_resources  = ARRAY_SIZE(ram_console_resource),
  2966.     .resource       = ram_console_resource,
  2967. };
  2968. #endif
  2969. //ZTE_WIFI_OYHQ_20100714 wifi froyo upgrade begin
  2970. /* ATHENV */
  2971. static struct platform_device msm_wlan_ar6000_pm_device = {
  2972.     .name       = "wlan_ar6000_pm_dev",
  2973.     .id     = 1,
  2974.     .num_resources  = 0,
  2975.     .resource   = NULL,
  2976. };
  2977. /* ATHENV */
  2978. //ZTE_WIFI_OYHQ_20100714 wifi froyo upgrade end
  2979. static struct platform_device *early_devices[] __initdata = {
  2980. #ifdef CONFIG_GPIOLIB
  2981.     &msm_gpio_devices[0],
  2982.     &msm_gpio_devices[1],
  2983.     &msm_gpio_devices[2],
  2984.     &msm_gpio_devices[3],
  2985.     &msm_gpio_devices[4],
  2986.     &msm_gpio_devices[5],
  2987. #endif
  2988. };
  2989.  
  2990. static struct platform_device *devices[] __initdata = {
  2991. //ZTE_WIFI_OYHQ_20100714 wifi froyo upgrade begin
  2992.     /* ATHENV */
  2993.     /*
  2994.      * It is necessary to put here in order to support WoW.
  2995.      * Put it before MMC host controller in worst case
  2996.      */
  2997.     &msm_wlan_ar6000_pm_device,
  2998. /* ATHENV */
  2999. //ZTE_WIFI_OYHQ_20100714 wifi froyo upgrade end
  3000. #if !defined(CONFIG_MSM_SERIAL_DEBUGGER)
  3001.     &msm_device_uart3,
  3002. #endif
  3003.     &msm_device_smd,
  3004.     &msm_device_dmov,
  3005.     &msm_device_nand,
  3006.  
  3007. #ifdef CONFIG_USB_MSM_OTG_72K
  3008.     &msm_device_otg,
  3009. #ifdef CONFIG_USB_GADGET
  3010.     &msm_device_gadget_peripheral,
  3011. #endif
  3012. #endif
  3013.  
  3014. #ifdef CONFIG_USB_FUNCTION
  3015.     &msm_device_hsusb_peripheral,
  3016.     &mass_storage_device,
  3017. #endif
  3018.  
  3019. #ifdef CONFIG_USB_ANDROID
  3020.     &usb_mass_storage_device,
  3021.     &rndis_device,
  3022. #ifdef CONFIG_USB_ANDROID_DIAG
  3023.     &usb_diag_device,
  3024. #endif
  3025.     &android_usb_device,
  3026. #endif
  3027.  
  3028.     &msm_device_i2c,
  3029. /*ZTE_AUX_FYA_001,@2010-02-06,BEGIN*/
  3030.     &aux_i2c_gpio_device,  
  3031. /*ZTE_AUX_FYA_001,@2010-02-06,END*/
  3032. /*ZTE_AUX2_FYA_001,@2010-02-06,BEGIN*/
  3033.     &aux2_i2c_gpio_device,  
  3034. /*ZTE_AUX2_FYA_001,@2010-02-06,END*/
  3035.     &smc91x_device,
  3036. /*ZTE_TSSC_WLY_001, @2010-04-13,BEGIN*/
  3037. #if defined( CONFIG_TOUCHSCREEN_MSM_LEGACY) || defined( CONFIG_TOUCHSCREEN_MSM)
  3038.     &msm_device_tssc,
  3039. #endif
  3040. /*ZTE_TSSC_WLY_001, @2010-04-13,BEGIN*/
  3041.     &android_pmem_kernel_ebi1_device,
  3042.     &android_pmem_device,
  3043.     &android_pmem_adsp_device,
  3044.     &android_pmem_audio_device,
  3045.     &msm_fb_device,
  3046. #ifdef CONFIG_ZTE_PLATFORM
  3047.     &lcdc_qvga_panel_device,
  3048. #else
  3049.     &lcdc_gordon_panel_device,
  3050. #endif
  3051.     &msm_device_uart_dm1,
  3052. #ifdef CONFIG_BT
  3053.     &msm_bt_power_device,
  3054.     &msm_bcm_power_device,  
  3055. #endif
  3056.     &msm_device_pmic_leds,
  3057.     &android_leds, //button-backlight
  3058.     &msm_device_snd,
  3059.     &msm_device_adspdec,
  3060. #ifdef CONFIG_MT9T013
  3061.     &msm_camera_sensor_mt9t013,
  3062. #endif
  3063. #ifdef CONFIG_MT9D112
  3064.     &msm_camera_sensor_mt9d112,
  3065. #endif
  3066. #ifdef CONFIG_S5K3E2FX
  3067.     &msm_camera_sensor_s5k3e2fx,
  3068. #endif
  3069. #ifdef CONFIG_MT9P012
  3070.     &msm_camera_sensor_mt9p012,
  3071. #endif
  3072. #ifdef CONFIG_MT9P012_KM
  3073.     &msm_camera_sensor_mt9p012_km,
  3074. #endif
  3075. #ifdef CONFIG_VB6801
  3076.     &msm_camera_sensor_vb6801,
  3077. #endif
  3078.     &msm_bluesleep_device,
  3079.     &msm_bcmsleep_device,    
  3080. #ifdef CONFIG_ARCH_MSM7X27
  3081.     &msm_device_kgsl,  
  3082. #endif
  3083. #ifdef CONFIG_MT9P111
  3084.     /*
  3085.      * Commented by zh.shj
  3086.      *
  3087.      * Refer to drivers/media/video/msm/mt9p111.c
  3088.      * For MT9P111: 5.0Mp, 1/4-Inch System-On-A-Chip (SOC) CMOS Digital Image Sensor
  3089.      */
  3090.     &msm_camera_sensor_mt9p111,
  3091. #endif
  3092.  
  3093. #ifdef CONFIG_MT9T11X
  3094.     /*
  3095.      * Commented by zh.shj, ZTE_MSM_CAMERA_ZHSHJ_001
  3096.      *
  3097.      * Refer to drivers/media/video/msm/mt9t11x.c
  3098.      * For MT9T111: 3.1Mp, 1/4-Inch System-On-A-Chip (SOC) CMOS Digital Image Sensor
  3099.      * For MT9T112: 3.1Mp, 1/4-Inch System-On-A-Chip (SOC) CMOS Digital Image Sensor
  3100.      */
  3101.     &msm_camera_sensor_mt9t11x,
  3102. #endif
  3103.  
  3104. #ifdef CONFIG_MT9D115
  3105.     /*
  3106.      * add by ZTE_CAMERA_LIJING_20100629 for MT9D115-2.0Mp-FF-Socket
  3107.      */
  3108.     &msm_camera_sensor_mt9d115,
  3109. #endif
  3110.  
  3111. #ifdef CONFIG_MT9V113
  3112.     /*
  3113.      * Commented by zh.shj
  3114.      *
  3115.      * Refer to drivers/media/video/msm/mt9v113.c
  3116.      * For MT9V113: 0.3Mp, 1/11-Inch System-On-A-Chip (SOC) CMOS Digital Image Sensor
  3117.      */
  3118.     &msm_camera_sensor_mt9v113,
  3119. #endif
  3120.  
  3121. #ifdef CONFIG_OV5642
  3122.     /*
  3123.      * Commented by zh.shj
  3124.      *
  3125.      * Refer to drivers/media/video/msm/ov5642.c
  3126.      * For OV5642: 5.0Mp, 1/4-Inch System-On-A-Chip (SOC) CMOS Digital Image Sensor
  3127.      */
  3128.     &msm_camera_sensor_ov5642,
  3129. #endif
  3130.  
  3131. #ifdef CONFIG_OV5640
  3132.  
  3133.     &msm_camera_sensor_ov5640,
  3134. #endif
  3135.  
  3136.     &hs_device,
  3137.     &msm_batt_device,
  3138. #ifdef CONFIG_ANDROID_RAM_CONSOLE
  3139.     &ram_console_device,
  3140. #endif
  3141. };
  3142.  
  3143. static struct msm_panel_common_pdata mdp_pdata = {
  3144.     .gpio = 97,
  3145. };
  3146.  
  3147. static void __init msm_fb_add_devices(void)
  3148. {
  3149.     msm_fb_register_device("mdp", &mdp_pdata);
  3150.     msm_fb_register_device("pmdh", 0);
  3151.     msm_fb_register_device("lcdc", &lcdc_pdata);
  3152. }
  3153.  
  3154. /*ZTE_AUX_FYA_001,@2010-02-06,BEGIN*/
  3155. static struct i2c_board_info aux_i2c_devices[] = {
  3156. #if 0
  3157.     {
  3158.         .type         = "avago_ofn",
  3159.         /*.flags        = ,*/
  3160.         .addr         = 0x33,
  3161.         .platform_data = &avago_ofn,
  3162.         .irq          = MSM_GPIO_TO_INT(35),
  3163.     },
  3164. #endif
  3165.     {
  3166.         I2C_BOARD_INFO("si4708", 0x10),
  3167.     },
  3168.     //ZTE_ALSPRX_001 start
  3169.     {
  3170.         .type         = "taos",
  3171.         .addr         = 0x39,
  3172.     },
  3173.     //ZTE_ALSPRX_001 end
  3174. };
  3175. /*ZTE_AUX_FYA_001,@2010-02-06,END*/
  3176.  
  3177. /*ZTE_AUX2_FYA_001,@2010-02-06,BEGIN+++++++++++*/
  3178.  
  3179.  
  3180. static struct i2c_board_info aux2_i2c_devices[] = {
  3181. #if 0
  3182.     {
  3183.         I2C_BOARD_INFO("akm8973", 0x1c),
  3184.     },
  3185.     {
  3186.         .type = "accelerator", //ZTE_FYA_20101122
  3187.         .addr = 0x1d,
  3188.     },
  3189. #endif
  3190. };
  3191. /*ZTE_AUX_FYA_001,@2010-02-06,END---------------*/
  3192. extern struct sys_timer msm_timer;
  3193.  
  3194. static void __init msm7x2x_init_irq(void)
  3195. {
  3196.     msm_init_irq();
  3197. }
  3198.  
  3199. static struct msm_acpu_clock_platform_data msm7x2x_clock_data = {
  3200.     .acpu_switch_time_us = 50,
  3201.     .max_speed_delta_khz = 400000,
  3202.     .vdd_switch_time_us = 62,
  3203.     .max_axi_khz = 160000,
  3204. };
  3205.  
  3206. void msm_serial_debug_init(unsigned int base, int irq,
  3207.                struct device *clk_device, int signal_irq);
  3208.  
  3209. #ifdef CONFIG_USB_EHCI_MSM
  3210. static void msm_hsusb_vbus_power(unsigned phy_info, int on)
  3211. {
  3212.     if (on)
  3213.         msm_hsusb_vbus_powerup();
  3214.     else
  3215.         msm_hsusb_vbus_shutdown();
  3216. }
  3217.  
  3218. static struct msm_usb_host_platform_data msm_usb_host_pdata = {
  3219.     .phy_info       = (USB_PHY_INTEGRATED | USB_PHY_MODEL_65NM),
  3220.     .vbus_power = msm_hsusb_vbus_power,
  3221. };
  3222. static void __init msm7x2x_init_host(void)
  3223. {
  3224.     if (machine_is_msm7x25_ffa() || machine_is_msm7x27_ffa())
  3225.         return;
  3226.  
  3227.     msm_add_host(0, &msm_usb_host_pdata);
  3228. }
  3229. #endif
  3230.  
  3231.  
  3232. #if (defined(CONFIG_MMC_MSM_SDC1_SUPPORT)\
  3233.     || defined(CONFIG_MMC_MSM_SDC2_SUPPORT)\
  3234.     || defined(CONFIG_MMC_MSM_SDC3_SUPPORT)\
  3235.     || defined(CONFIG_MMC_MSM_SDC4_SUPPORT))
  3236.  
  3237. static unsigned long vreg_sts, gpio_sts;
  3238. static struct vreg *vreg_mmc;
  3239. static unsigned mpp_mmc = 2;
  3240.  
  3241. struct sdcc_gpio {
  3242.     struct msm_gpio *cfg_data;
  3243.     uint32_t size;
  3244.     struct msm_gpio *sleep_cfg_data;
  3245. };
  3246.  
  3247. static struct msm_gpio sdc1_cfg_data[] = {
  3248.     {GPIO_CFG(51, 1, GPIO_OUTPUT, GPIO_PULL_UP, GPIO_8MA), "sdc1_dat_3"},
  3249.     {GPIO_CFG(52, 1, GPIO_OUTPUT, GPIO_PULL_UP, GPIO_8MA), "sdc1_dat_2"},
  3250.     {GPIO_CFG(53, 1, GPIO_OUTPUT, GPIO_PULL_UP, GPIO_8MA), "sdc1_dat_1"},
  3251.     {GPIO_CFG(54, 1, GPIO_OUTPUT, GPIO_PULL_UP, GPIO_8MA), "sdc1_dat_0"},
  3252.     {GPIO_CFG(55, 1, GPIO_OUTPUT, GPIO_PULL_UP, GPIO_8MA), "sdc1_cmd"},
  3253.     {GPIO_CFG(56, 1, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_8MA), "sdc1_clk"},
  3254. };
  3255.  
  3256. static struct msm_gpio sdc2_cfg_data[] = {
  3257.     {GPIO_CFG(62, 2, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_8MA), "sdc2_clk"},
  3258.     {GPIO_CFG(63, 2, GPIO_OUTPUT, GPIO_PULL_UP, GPIO_8MA), "sdc2_cmd"},
  3259.     {GPIO_CFG(64, 2, GPIO_OUTPUT, GPIO_PULL_UP, GPIO_8MA), "sdc2_dat_3"},
  3260.     {GPIO_CFG(65, 2, GPIO_OUTPUT, GPIO_PULL_UP, GPIO_8MA), "sdc2_dat_2"},
  3261.     {GPIO_CFG(66, 2, GPIO_OUTPUT, GPIO_PULL_UP, GPIO_8MA), "sdc2_dat_1"},
  3262.     {GPIO_CFG(67, 2, GPIO_OUTPUT, GPIO_PULL_UP, GPIO_8MA), "sdc2_dat_0"},
  3263. };
  3264.  
  3265. static struct msm_gpio sdc2_sleep_cfg_data[] = {
  3266.     {GPIO_CFG(62, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), "sdc2_clk"},
  3267.     {GPIO_CFG(63, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), "sdc2_cmd"},
  3268.     {GPIO_CFG(64, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), "sdc2_dat_3"},
  3269.     {GPIO_CFG(65, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), "sdc2_dat_2"},
  3270.     {GPIO_CFG(66, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), "sdc2_dat_1"},
  3271.     {GPIO_CFG(67, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA), "sdc2_dat_0"},
  3272. };
  3273. static struct msm_gpio sdc3_cfg_data[] = {
  3274.     {GPIO_CFG(88, 1, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_8MA), "sdc3_clk"},
  3275.     {GPIO_CFG(89, 1, GPIO_OUTPUT, GPIO_PULL_UP, GPIO_8MA), "sdc3_cmd"},
  3276.     {GPIO_CFG(90, 1, GPIO_OUTPUT, GPIO_PULL_UP, GPIO_8MA), "sdc3_dat_3"},
  3277.     {GPIO_CFG(91, 1, GPIO_OUTPUT, GPIO_PULL_UP, GPIO_8MA), "sdc3_dat_2"},
  3278.     {GPIO_CFG(92, 1, GPIO_OUTPUT, GPIO_PULL_UP, GPIO_8MA), "sdc3_dat_1"},
  3279.     {GPIO_CFG(93, 1, GPIO_OUTPUT, GPIO_PULL_UP, GPIO_8MA), "sdc3_dat_0"},
  3280. };
  3281.  
  3282. static struct msm_gpio sdc4_cfg_data[] = {
  3283.     {GPIO_CFG(19, 3, GPIO_OUTPUT, GPIO_PULL_UP, GPIO_8MA), "sdc4_dat_3"},
  3284.     {GPIO_CFG(20, 3, GPIO_OUTPUT, GPIO_PULL_UP, GPIO_8MA), "sdc4_dat_2"},
  3285.     {GPIO_CFG(21, 4, GPIO_OUTPUT, GPIO_PULL_UP, GPIO_8MA), "sdc4_dat_1"},
  3286.     {GPIO_CFG(107, 1, GPIO_OUTPUT, GPIO_PULL_UP, GPIO_8MA), "sdc4_cmd"},
  3287.     {GPIO_CFG(108, 1, GPIO_OUTPUT, GPIO_PULL_UP, GPIO_8MA), "sdc4_dat_0"},
  3288.     {GPIO_CFG(109, 1, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_8MA), "sdc4_clk"},
  3289. };
  3290.  
  3291. static struct sdcc_gpio sdcc_cfg_data[] = {
  3292.     {
  3293.         .cfg_data = sdc1_cfg_data,
  3294.         .size = ARRAY_SIZE(sdc1_cfg_data),
  3295.         .sleep_cfg_data = NULL,
  3296.     },
  3297.     {
  3298.         .cfg_data = sdc2_cfg_data,
  3299.         .size = ARRAY_SIZE(sdc2_cfg_data),
  3300.         .sleep_cfg_data = sdc2_sleep_cfg_data,
  3301.     },
  3302.     {
  3303.         .cfg_data = sdc3_cfg_data,
  3304.         .size = ARRAY_SIZE(sdc3_cfg_data),
  3305.         .sleep_cfg_data = NULL,
  3306.     },
  3307.     {
  3308.         .cfg_data = sdc4_cfg_data,
  3309.         .size = ARRAY_SIZE(sdc4_cfg_data),
  3310.         .sleep_cfg_data = NULL,
  3311.     },
  3312. };
  3313.  
  3314. static void msm_sdcc_setup_gpio(int dev_id, unsigned int enable)
  3315. {
  3316.     int rc = 0;
  3317.     struct sdcc_gpio *curr;
  3318.  
  3319.     curr = &sdcc_cfg_data[dev_id - 1];
  3320.     if (!(test_bit(dev_id, &gpio_sts)^enable))
  3321.         return;
  3322.  
  3323.     if (enable) {
  3324.         set_bit(dev_id, &gpio_sts);
  3325.         rc = msm_gpios_request_enable(curr->cfg_data, curr->size);
  3326.         if (rc)
  3327.             printk(KERN_ERR "%s: Failed to turn on GPIOs for slot %d\n",
  3328.                 __func__,  dev_id);
  3329.     } else {
  3330.         clear_bit(dev_id, &gpio_sts);
  3331.         if (curr->sleep_cfg_data) {
  3332.             msm_gpios_enable(curr->sleep_cfg_data, curr->size);
  3333.             msm_gpios_free(curr->sleep_cfg_data, curr->size);
  3334.             return;
  3335.         }
  3336.         msm_gpios_disable_free(curr->cfg_data, curr->size);
  3337.     }
  3338. }
  3339.  
  3340. static uint32_t msm_sdcc_setup_power(struct device *dv, unsigned int vdd)
  3341. {
  3342.     int rc = 0;
  3343.     struct platform_device *pdev;
  3344.  
  3345.     pdev = container_of(dv, struct platform_device, dev);
  3346.     msm_sdcc_setup_gpio(pdev->id, !!vdd);
  3347.  
  3348.     if (vdd == 0) {
  3349.         if (!vreg_sts)
  3350.             return 0;
  3351.  
  3352.         clear_bit(pdev->id, &vreg_sts);
  3353.  
  3354.         if (!vreg_sts) {
  3355.             if (machine_is_msm7x25_ffa() ||
  3356.                     machine_is_msm7x27_ffa()) {
  3357.                 rc = mpp_config_digital_out(mpp_mmc,
  3358.                      MPP_CFG(MPP_DLOGIC_LVL_MSMP,
  3359.                      MPP_DLOGIC_OUT_CTRL_LOW));
  3360.             } else
  3361.                 rc = vreg_disable(vreg_mmc);
  3362.             if (rc)
  3363.                 printk(KERN_ERR "%s: return val: %d \n",
  3364.                     __func__, rc);
  3365.         }
  3366.         return 0;
  3367.     }
  3368.  
  3369.     if (!vreg_sts) {
  3370.         if (machine_is_msm7x25_ffa() || machine_is_msm7x27_ffa()) {
  3371.             rc = mpp_config_digital_out(mpp_mmc,
  3372.                  MPP_CFG(MPP_DLOGIC_LVL_MSMP,
  3373.                  MPP_DLOGIC_OUT_CTRL_HIGH));
  3374.         } else {
  3375.             rc = vreg_set_level(vreg_mmc, 2850);
  3376.             if (!rc)
  3377.                 rc = vreg_enable(vreg_mmc);
  3378.         }
  3379.         if (rc)
  3380.             printk(KERN_ERR "%s: return val: %d \n",
  3381.                     __func__, rc);
  3382.     }
  3383.     set_bit(pdev->id, &vreg_sts);
  3384.     return 0;
  3385. }
  3386. //ZTE_WIFI_OYHQ_20100714 wifi froyo upgrade begin
  3387. /* ATHENV+++ */
  3388. static void (*wifi_status_notify_cb)(int card_present, void *dev_id);
  3389. void *wifi_devid;
  3390. //static int msm_sdcc_register_status_notify(void (*callback)(int card_present, void *dev_id), void *dev_id)
  3391. //{
  3392. //  wifi_status_notify_cb = callback;
  3393. //  wifi_devid = dev_id;
  3394. //  printk("%s: callback %p devid %p\n", __func__, callback, dev_id);
  3395. //  return 0;
  3396. //}
  3397.  
  3398. void wifi_detect_change(int on)
  3399. {
  3400.     if (wifi_status_notify_cb) {
  3401.         printk("%s: callback %p devid %p is called!!\n", __func__, wifi_status_notify_cb, wifi_devid);
  3402.         wifi_status_notify_cb(on, wifi_devid);
  3403.     }
  3404. }
  3405. EXPORT_SYMBOL(wifi_detect_change);
  3406. /* ATHENV---*/
  3407. //ZTE_WIFI_OYHQ_20100714 wifi froyo upgrade end
  3408. #ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
  3409. static struct mmc_platform_data msm7x2x_sdc1_data = {
  3410.     .ocr_mask   = MMC_VDD_28_29,
  3411.     .translate_vdd  = msm_sdcc_setup_power,
  3412.     .mmc_bus_width  = MMC_CAP_4_BIT_DATA,
  3413.     .msmsdcc_fmin   = 144000,
  3414.     .msmsdcc_fmid   = 24576000,
  3415.     .msmsdcc_fmax   = 49152000,
  3416.     .nonremovable   = 1,
  3417. };
  3418. #endif
  3419.  
  3420. #ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
  3421. static struct mmc_platform_data msm7x2x_sdc2_data = {
  3422.     .ocr_mask   = MMC_VDD_28_29,
  3423.     .translate_vdd  = msm_sdcc_setup_power,
  3424.     .mmc_bus_width  = MMC_CAP_4_BIT_DATA,
  3425. #ifdef CONFIG_MMC_MSM_SDIO_SUPPORT
  3426. #if 0    //ZTE_ZBS_20110308 : disable the SDIO irq wakeup
  3427.     .sdiowakeup_irq = MSM_GPIO_TO_INT(66),
  3428. #endif
  3429. #endif
  3430.     .msmsdcc_fmin   = 144000,
  3431.     .msmsdcc_fmid   = 24576000,
  3432.     .msmsdcc_fmax   = 49152000,
  3433.     .nonremovable   = 0,
  3434.     //ZTE_WIFI_OYHQ_20100714 wifi froyo upgrade begin
  3435.     .dummy52_required = 1,
  3436.     //ZTE_WIFI_OYHQ_20100714 wifi froyo upgrade end
  3437. };
  3438. #endif
  3439.  
  3440. #ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
  3441. static struct mmc_platform_data msm7x2x_sdc3_data = {
  3442.     .ocr_mask   = MMC_VDD_28_29,
  3443.     .translate_vdd  = msm_sdcc_setup_power,
  3444.     .mmc_bus_width  = MMC_CAP_4_BIT_DATA,
  3445.     .msmsdcc_fmin   = 144000,
  3446.     .msmsdcc_fmid   = 24576000,
  3447.     .msmsdcc_fmax   = 49152000,
  3448.     .nonremovable   = 0,
  3449. };
  3450. #endif
  3451.  
  3452. #ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
  3453. static struct mmc_platform_data msm7x2x_sdc4_data = {
  3454.     .ocr_mask   = MMC_VDD_28_29,
  3455.     .translate_vdd  = msm_sdcc_setup_power,
  3456.     .mmc_bus_width  = MMC_CAP_4_BIT_DATA,
  3457.     .msmsdcc_fmin   = 144000,
  3458.     .msmsdcc_fmid   = 24576000,
  3459.     .msmsdcc_fmax   = 49152000,
  3460.     .nonremovable   = 0,
  3461. };
  3462. #endif
  3463.  
  3464. static void __init msm7x2x_init_mmc(void)
  3465. {
  3466.     if (!machine_is_msm7x25_ffa() && !machine_is_msm7x27_ffa()) {
  3467.         vreg_mmc = vreg_get(NULL, "mmc");
  3468.         if (IS_ERR(vreg_mmc)) {
  3469.             printk(KERN_ERR "%s: vreg get failed (%ld)\n",
  3470.                    __func__, PTR_ERR(vreg_mmc));
  3471.             return;
  3472.         }
  3473.     }
  3474.  
  3475. #ifdef CONFIG_MMC_MSM_SDC1_SUPPORT
  3476.     if (machine_is_msm7x27_ffa())
  3477.         msm7x2x_sdc1_data.nonremovable = 0;
  3478.     msm_add_sdcc(1, &msm7x2x_sdc1_data);
  3479.  
  3480. #endif
  3481. //ZTE_WIFI_OYHQ_20100714 wifi froyo upgrade begin
  3482. //if (machine_is_msm7x25_surf() || machine_is_msm7x27_surf() ||
  3483. //machine_is_msm7x27_ffa()) {
  3484. #ifdef CONFIG_MMC_MSM_SDC2_SUPPORT
  3485.         if (machine_is_msm7x27_ffa())
  3486.             msm7x2x_sdc2_data.nonremovable = 1;
  3487.         msm_sdcc_setup_gpio(2, 1);
  3488.         msm_add_sdcc(2, &msm7x2x_sdc2_data);
  3489. #endif
  3490. //}
  3491.     if (machine_is_msm7x25_surf() || machine_is_msm7x27_surf()) {
  3492. #ifdef CONFIG_MMC_MSM_SDC3_SUPPORT
  3493.         msm_add_sdcc(3, &msm7x2x_sdc3_data);
  3494. #endif
  3495. #ifdef CONFIG_MMC_MSM_SDC4_SUPPORT
  3496.         msm_add_sdcc(4, &msm7x2x_sdc4_data);
  3497. #endif
  3498.     }
  3499. }
  3500. #else
  3501. #define msm7x2x_init_mmc() do {} while (0)
  3502. #endif
  3503.  
  3504.  
  3505. static struct msm_pm_platform_data msm7x25_pm_data[MSM_PM_SLEEP_MODE_NR] = {
  3506.     [MSM_PM_SLEEP_MODE_POWER_COLLAPSE].latency = 16000,
  3507.  
  3508.     [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN].latency = 12000,
  3509.  
  3510.     [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency = 2000,
  3511. };
  3512.  
  3513. static struct msm_pm_platform_data msm7x27_pm_data[MSM_PM_SLEEP_MODE_NR] = {
  3514.     [MSM_PM_SLEEP_MODE_POWER_COLLAPSE].supported = 1,
  3515.     [MSM_PM_SLEEP_MODE_POWER_COLLAPSE].suspend_enabled = 1,
  3516.     [MSM_PM_SLEEP_MODE_POWER_COLLAPSE].idle_enabled = 1,
  3517.     [MSM_PM_SLEEP_MODE_POWER_COLLAPSE].latency = 16000,
  3518.     [MSM_PM_SLEEP_MODE_POWER_COLLAPSE].residency = 20000,
  3519.  
  3520.     [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN].supported = 1,
  3521.     [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN].suspend_enabled = 1,
  3522.     [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN].idle_enabled = 1,
  3523.     [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN].latency = 12000,
  3524.     [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN].residency = 20000,
  3525.  
  3526.     [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].supported = 1,
  3527.     [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].suspend_enabled
  3528.         = 1,
  3529.     [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].idle_enabled = 1,
  3530.     [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency = 2000,
  3531.     [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].residency = 0,
  3532. };
  3533.  
  3534. static void
  3535. msm_i2c_gpio_config(int iface, int config_type)
  3536. {
  3537.     int gpio_scl;
  3538.     int gpio_sda;
  3539.     if (iface) {
  3540.         gpio_scl = 95;
  3541.         gpio_sda = 96;
  3542.     } else {
  3543.         gpio_scl = 60;
  3544.         gpio_sda = 61;
  3545.     }
  3546.     if (config_type) {
  3547.         gpio_tlmm_config(GPIO_CFG(gpio_scl, 1, GPIO_INPUT,
  3548.                     GPIO_NO_PULL, GPIO_16MA), GPIO_ENABLE);
  3549.         gpio_tlmm_config(GPIO_CFG(gpio_sda, 1, GPIO_INPUT,
  3550.                     GPIO_NO_PULL, GPIO_16MA), GPIO_ENABLE);
  3551.     } else {
  3552.         gpio_tlmm_config(GPIO_CFG(gpio_scl, 0, GPIO_OUTPUT,
  3553.                     GPIO_NO_PULL, GPIO_16MA), GPIO_ENABLE);
  3554.         gpio_tlmm_config(GPIO_CFG(gpio_sda, 0, GPIO_OUTPUT,
  3555.                     GPIO_NO_PULL, GPIO_16MA), GPIO_ENABLE);
  3556.     }
  3557. }
  3558.  
  3559. static struct msm_i2c_platform_data msm_i2c_pdata = {
  3560.  
  3561.     .clk_freq = 100000,
  3562.     .rmutex  = 0,
  3563.     .pri_clk = 60,
  3564.     .pri_dat = 61,
  3565.  
  3566.  
  3567. #if 0
  3568.     .aux_clk = 95,
  3569.     .aux_dat = 96,
  3570. #endif
  3571.  
  3572.     .msm_i2c_config_gpio = msm_i2c_gpio_config,
  3573. };
  3574.  
  3575. static void __init msm_device_i2c_init(void)
  3576. {
  3577.     if (gpio_request(60, "i2c_pri_clk"))
  3578.         pr_err("failed to request gpio i2c_pri_clk\n");
  3579.     if (gpio_request(61, "i2c_pri_dat"))
  3580.         pr_err("failed to request gpio i2c_pri_dat\n");
  3581.  
  3582.  
  3583. #if 0
  3584.     if (gpio_request(95, "i2c_sec_clk"))
  3585.         pr_err("failed to request gpio i2c_sec_clk\n");
  3586.     if (gpio_request(96, "i2c_sec_dat"))
  3587.         pr_err("failed to request gpio i2c_sec_dat\n");
  3588. #endif
  3589.  
  3590.     if (cpu_is_msm7x27())
  3591.         msm_i2c_pdata.pm_lat =
  3592.         msm7x27_pm_data[MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN]
  3593.         .latency;
  3594.     else
  3595.         msm_i2c_pdata.pm_lat =
  3596.         msm7x25_pm_data[MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN]
  3597.         .latency;
  3598.  
  3599.     msm_device_i2c.dev.platform_data = &msm_i2c_pdata;
  3600. }
  3601.  
  3602. #ifdef CONFIG_ZTE_PLATFORM
  3603. #define MSM_GPIO_USB3V3     21
  3604. static unsigned usb_config_power_on =   GPIO_CFG(MSM_GPIO_USB3V3, 0,
  3605.                                                                                 GPIO_OUTPUT, GPIO_PULL_UP, GPIO_2MA);
  3606. static int init_usb3v3(void)
  3607. {
  3608.     int rc;
  3609.     rc = gpio_tlmm_config(usb_config_power_on,GPIO_ENABLE);
  3610.     if (rc) {
  3611.         printk(KERN_ERR "%s: gpio_tlmm_config(%#x)=%d\n",__func__, MSM_GPIO_USB3V3, rc);
  3612.         return -EIO;
  3613.     }
  3614.     rc = gpio_request(MSM_GPIO_USB3V3, "usb");
  3615.     if(!rc)
  3616.     {
  3617.         gpio_direction_output(MSM_GPIO_USB3V3, 1);
  3618.         gpio_set_value(MSM_GPIO_USB3V3, 1);
  3619.         printk(KERN_ERR "gpio_request: %d ok!\n", MSM_GPIO_USB3V3);
  3620.     }
  3621.     else
  3622.     {
  3623.         printk(KERN_ERR "gpio_request: %d failed!\n", MSM_GPIO_USB3V3);
  3624.     }
  3625.     gpio_free(MSM_GPIO_USB3V3);
  3626.     return 0;
  3627. }  
  3628.  
  3629. #endif
  3630.  
  3631. static void usb_mpp_init(void)
  3632. {
  3633.     unsigned rc;
  3634.     unsigned mpp_usb = 7;
  3635.  
  3636.     if (machine_is_msm7x25_ffa() || machine_is_msm7x27_ffa()) {
  3637.         rc = mpp_config_digital_out(mpp_usb,
  3638.             MPP_CFG(MPP_DLOGIC_LVL_VDD,
  3639.                 MPP_DLOGIC_OUT_CTRL_HIGH));
  3640.         if (rc)
  3641.             pr_err("%s: configuring mpp pin"
  3642.                 "to enable 3.3V LDO failed\n", __func__);
  3643.     }
  3644. }
  3645.  
  3646.  extern void  __init msm_init_pmic_vibrator(void);
  3647.  
  3648. static ssize_t debug_global_read(struct file *file, char __user *buf,
  3649.                     size_t len, loff_t *offset)
  3650. {
  3651.     loff_t pos = *offset;
  3652.     ssize_t count;
  3653.     ssize_t size;
  3654.  
  3655.     size = sizeof(smem_global);
  3656.  
  3657.     if (pos >= size)
  3658.         return 0;
  3659.  
  3660.     count = min(len, (size_t)(size - pos));
  3661.     if (copy_to_user(buf, (char *)global + pos, count))
  3662.         return -EFAULT;
  3663.  
  3664.     *offset += count;
  3665.     return count;
  3666. }
  3667.  
  3668. static struct file_operations debug_global_file_ops = {
  3669.     .owner = THIS_MODULE,
  3670.     .read = debug_global_read,
  3671. };
  3672.  
  3673. static void msm7x27_wlan_init(void)
  3674. {
  3675.     int rc = 0;
  3676.     /* TBD: if (machine_is_msm7x27_ffa_with_wcn1312()) */
  3677.     if (machine_is_msm7x27_ffa()) {
  3678.         rc = mpp_config_digital_out(3, MPP_CFG(MPP_DLOGIC_LVL_MSMP,
  3679.                 MPP_DLOGIC_OUT_CTRL_LOW));
  3680.         if (rc)
  3681.             printk(KERN_ERR "%s: return val: %d \n",
  3682.                 __func__, rc);
  3683.     }
  3684. }
  3685.  
  3686. static void __init msm7x2x_init(void)
  3687. {
  3688.     struct proc_dir_entry *entry;
  3689.    
  3690. #ifdef CONFIG_ZTE_FTM_FLAG_SUPPORT
  3691.     zte_ftm_set_value(g_zte_ftm_flag_fixup);
  3692. #endif
  3693.  
  3694.     if (socinfo_init() < 0)
  3695.         BUG();
  3696. #ifdef CONFIG_ARCH_MSM7X25
  3697.     msm_clock_init(msm_clocks_7x25, msm_num_clocks_7x25);
  3698. #elif CONFIG_ARCH_MSM7X27
  3699.     msm_clock_init(msm_clocks_7x27, msm_num_clocks_7x27);
  3700. #endif
  3701.     platform_add_devices(early_devices, ARRAY_SIZE(early_devices));
  3702.  
  3703. #if defined(CONFIG_MSM_SERIAL_DEBUGGER)
  3704.     msm_serial_debug_init(MSM_UART3_PHYS, INT_UART3,
  3705.             &msm_device_uart3.dev, 1);
  3706. #endif
  3707.     if (machine_is_msm7x25_ffa() || machine_is_msm7x27_ffa()) {
  3708.         smc91x_resources[0].start = 0x98000300;
  3709.         smc91x_resources[0].end = 0x980003ff;
  3710.         smc91x_resources[1].start = MSM_GPIO_TO_INT(85);
  3711.         smc91x_resources[1].end = MSM_GPIO_TO_INT(85);
  3712.         if (gpio_tlmm_config(GPIO_CFG(85, 0,
  3713.                           GPIO_INPUT,
  3714.                           GPIO_PULL_DOWN,
  3715.                           GPIO_2MA),
  3716.                      GPIO_ENABLE)) {
  3717.             printk(KERN_ERR
  3718.                    "%s: Err: Config GPIO-85 INT\n",
  3719.                 __func__);
  3720.         }
  3721.     }
  3722.  
  3723.     if (cpu_is_msm7x27())
  3724.         msm7x2x_clock_data.max_axi_khz = 200000;
  3725.  
  3726.     msm_acpu_clock_init(&msm7x2x_clock_data);
  3727. #ifdef CONFIG_ZTE_PLATFORM
  3728.     init_usb3v3();
  3729.     #endif
  3730. #ifdef CONFIG_ARCH_MSM7X27
  3731.     /* This value has been set to 160000 for power savings. */
  3732.     /* OEMs may modify the value at their discretion for performance */
  3733.     /* The appropriate maximum replacement for 160000 is: */
  3734.     /* clk_get_max_axi_khz() */
  3735.     kgsl_pdata.high_axi_3d = 160000;
  3736.  
  3737.     /* 7x27 doesn't allow graphics clocks to be run asynchronously to */
  3738.     /* the AXI bus */
  3739.     kgsl_pdata.max_grp2d_freq = 0;
  3740.     kgsl_pdata.min_grp2d_freq = 0;
  3741.     kgsl_pdata.set_grp2d_async = NULL;
  3742.     kgsl_pdata.max_grp3d_freq = 0;
  3743.     kgsl_pdata.min_grp3d_freq = 0;
  3744.     kgsl_pdata.set_grp3d_async = NULL;
  3745.     kgsl_pdata.imem_clk_name = "imem_clk";
  3746.     kgsl_pdata.grp3d_clk_name = "grp_clk";
  3747.     kgsl_pdata.grp3d_pclk_name = "grp_pclk";
  3748.     kgsl_pdata.grp2d0_clk_name = NULL;
  3749.     kgsl_pdata.idle_timeout_3d = HZ/5;
  3750.     kgsl_pdata.idle_timeout_2d = 0;
  3751. #ifdef CONFIG_KGSL_PER_PROCESS_PAGE_TABLE
  3752.     kgsl_pdata.pt_va_size = SZ_32M;
  3753. #else
  3754.     kgsl_pdata.pt_va_size = SZ_128M;
  3755. #endif
  3756. #endif
  3757.  
  3758. #if defined( CONFIG_TOUCHSCREEN_MSM_LEGACY) || defined( CONFIG_TOUCHSCREEN_MSM)
  3759.     msm_device_tssc.dev.platform_data = &msm_tssc_pdata;
  3760. #endif
  3761.  
  3762.     usb_mpp_init();
  3763.  
  3764. #ifdef CONFIG_USB_FUNCTION
  3765.     msm_hsusb_pdata.swfi_latency =
  3766.         msm7x27_pm_data
  3767.         [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency;
  3768.  
  3769.     msm_device_hsusb_peripheral.dev.platform_data = &msm_hsusb_pdata;
  3770. #endif
  3771.  
  3772. #ifdef CONFIG_USB_MSM_OTG_72K
  3773.     msm_device_otg.dev.platform_data = &msm_otg_pdata;
  3774.     if (machine_is_msm7x25_surf() || machine_is_msm7x25_ffa()) {
  3775.         msm_otg_pdata.pemp_level =
  3776.             PRE_EMPHASIS_WITH_20_PERCENT;
  3777.         msm_otg_pdata.drv_ampl = HS_DRV_AMPLITUDE_5_PERCENT;
  3778.         msm_otg_pdata.cdr_autoreset = CDR_AUTO_RESET_ENABLE;
  3779.         msm_otg_pdata.phy_reset_sig_inverted = 1;
  3780.     }
  3781.     if (machine_is_msm7x27_surf() || machine_is_msm7x27_ffa()) {
  3782.         msm_otg_pdata.pemp_level =
  3783.             PRE_EMPHASIS_WITH_10_PERCENT;
  3784.         msm_otg_pdata.drv_ampl = HS_DRV_AMPLITUDE_5_PERCENT;
  3785.         msm_otg_pdata.cdr_autoreset = CDR_AUTO_RESET_DISABLE;
  3786.         msm_otg_pdata.phy_reset_sig_inverted = 1;
  3787.     }
  3788.  
  3789. #ifdef CONFIG_USB_GADGET
  3790. //  msm_gadget_pdata.swfi_latency =
  3791. //      msm7x27_pm_data
  3792. //      [MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT].latency;
  3793. //  msm_device_gadget_peripheral.dev.platform_data = &msm_gadget_pdata;
  3794. #endif
  3795. #endif
  3796.     msm_init_pmic_vibrator();
  3797.  
  3798.     platform_add_devices(devices, ARRAY_SIZE(devices));
  3799. #ifdef CONFIG_MSM_CAMERA
  3800. //  config_camera_off_gpios(); /* might not be necessary */
  3801. #endif
  3802.     msm_device_i2c_init();
  3803.     i2c_register_board_info(0, i2c_devices, ARRAY_SIZE(i2c_devices));
  3804.     i2c_register_board_info(1, aux_i2c_devices, ARRAY_SIZE(aux_i2c_devices));
  3805.     i2c_register_board_info(2, aux2_i2c_devices, ARRAY_SIZE(aux2_i2c_devices));
  3806. #ifdef CONFIG_SURF_FFA_GPIO_KEYPAD
  3807.     if (machine_is_msm7x25_ffa() || machine_is_msm7x27_ffa())
  3808.         platform_device_register(&keypad_device_7k_ffa);
  3809.     else
  3810.         platform_device_register(&keypad_device_surf);
  3811. #endif
  3812. #ifdef CONFIG_ZTE_PLATFORM
  3813.     lcdc_lead_gpio_init();
  3814. #else
  3815.     lcdc_gordon_gpio_init();
  3816. #endif
  3817.     msm_fb_add_devices();
  3818. #ifdef CONFIG_USB_EHCI_MSM
  3819.     msm7x2x_init_host();
  3820. #endif
  3821.     msm7x2x_init_mmc();
  3822.     bt_power_init();
  3823.  
  3824.     if (cpu_is_msm7x27())
  3825.         msm_pm_set_platform_data(msm7x27_pm_data,
  3826.                     ARRAY_SIZE(msm7x27_pm_data));
  3827.     else
  3828.         msm_pm_set_platform_data(msm7x25_pm_data,
  3829.                     ARRAY_SIZE(msm7x25_pm_data));
  3830.                    
  3831.     msm7x27_wlan_init();               
  3832.    
  3833.     global = ioremap(SMEM_LOG_GLOBAL_BASE, sizeof(smem_global));
  3834.     if (!global) {
  3835.         printk(KERN_ERR "ioremap failed with SCL_SMEM_LOG_RAM_BASE\n");
  3836.         return;
  3837.     }
  3838.     entry = create_proc_entry("smem_global", S_IFREG | S_IRUGO, NULL);
  3839.     if (!entry) {
  3840.         printk(KERN_ERR "smem_global: failed to create proc entry\n");
  3841.         return;
  3842.     }
  3843.     entry->proc_fops = &debug_global_file_ops;
  3844.     entry->size = sizeof(smem_global);
  3845. }
  3846.  
  3847. static unsigned pmem_kernel_ebi1_size = PMEM_KERNEL_EBI1_SIZE;
  3848. static void __init pmem_kernel_ebi1_size_setup(char **p)
  3849. {
  3850.     pmem_kernel_ebi1_size = memparse(*p, p);
  3851. }
  3852. __early_param("pmem_kernel_ebi1_size=", pmem_kernel_ebi1_size_setup);
  3853.  
  3854. static unsigned pmem_mdp_size = MSM_PMEM_MDP_SIZE;
  3855. static void __init pmem_mdp_size_setup(char **p)
  3856. {
  3857.     pmem_mdp_size = memparse(*p, p);
  3858. }
  3859. __early_param("pmem_mdp_size=", pmem_mdp_size_setup);
  3860.  
  3861. static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
  3862. static void __init pmem_adsp_size_setup(char **p)
  3863. {
  3864.     pmem_adsp_size = memparse(*p, p);
  3865. }
  3866. __early_param("pmem_adsp_size=", pmem_adsp_size_setup);
  3867.  
  3868. static unsigned fb_size = MSM_FB_SIZE;
  3869. static void __init fb_size_setup(char **p)
  3870. {
  3871.     fb_size = memparse(*p, p);
  3872. }
  3873. __early_param("fb_size=", fb_size_setup);
  3874.  
  3875. static void __init msm_msm7x2x_allocate_memory_regions(void)
  3876. {
  3877.     void *addr;
  3878.     unsigned long size;
  3879.  
  3880. #if defined(CONFIG_ZTE_PLATFORM) && defined(CONFIG_F3_LOG)
  3881.     unsigned int len;
  3882.     smem_global *global_tmp = (smem_global *)(MSM_RAM_LOG_BASE + PAGE_SIZE) ;
  3883.  
  3884.     len = global_tmp->f3log;
  3885. #endif
  3886.  
  3887.     size = pmem_mdp_size;
  3888.     if (size) {
  3889.         addr = alloc_bootmem(size);
  3890.         android_pmem_pdata.start = __pa(addr);
  3891.         android_pmem_pdata.size = size;
  3892.         pr_info("allocating %lu bytes at %p (%lx physical) for mdp "
  3893.             "pmem arena\n", size, addr, __pa(addr));
  3894.     }
  3895.  
  3896.     size = pmem_adsp_size;
  3897.     if (size) {
  3898.         addr = alloc_bootmem(size);
  3899.         android_pmem_adsp_pdata.start = __pa(addr);
  3900.         android_pmem_adsp_pdata.size = size;
  3901.         pr_info("allocating %lu bytes at %p (%lx physical) for adsp "
  3902.             "pmem arena\n", size, addr, __pa(addr));
  3903.     }
  3904.  
  3905.     size = MSM_PMEM_AUDIO_SIZE ;
  3906.     android_pmem_audio_pdata.start = MSM_PMEM_AUDIO_START_ADDR ;
  3907.     android_pmem_audio_pdata.size = size;
  3908.     pr_info("allocating %lu bytes (at %lx physical) for audio "
  3909.         "pmem arena\n", size , MSM_PMEM_AUDIO_START_ADDR);
  3910.  
  3911.     size = fb_size ? : MSM_FB_SIZE;
  3912.     addr = alloc_bootmem(size);
  3913.     msm_fb_resources[0].start = __pa(addr);
  3914.     msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
  3915.     pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
  3916.         size, addr, __pa(addr));
  3917.  
  3918.     size = pmem_kernel_ebi1_size;
  3919.     if (size) {
  3920.         addr = alloc_bootmem_aligned(size, 0x100000);
  3921.         android_pmem_kernel_ebi1_pdata.start = __pa(addr);
  3922.         android_pmem_kernel_ebi1_pdata.size = size;
  3923.         pr_info("allocating %lu bytes at %p (%lx physical) for kernel"
  3924.             " ebi1 pmem arena\n", size, addr, __pa(addr));
  3925.     }
  3926.  
  3927. #if defined(CONFIG_ZTE_PLATFORM) && defined(CONFIG_F3_LOG)
  3928.     pr_info("length = %d ++ \n", len);
  3929.  
  3930.     if (len > 12)
  3931.         len = 12;
  3932.     else
  3933.         len = len/2*2;
  3934.    
  3935.     pr_info("length = %d -- \n", len);
  3936.     size = len;
  3937.    
  3938.     if (size)
  3939.         reserve_bootmem(0x08D00000, size*0x100000, BOOTMEM_DEFAULT);
  3940.  
  3941.     addr = phys_to_virt(0x08D00000);
  3942.     pr_info("allocating %lu M at %p (%lx physical) for F3\n",size, addr, __pa(addr));
  3943. #endif
  3944.  
  3945. }
  3946.  
  3947. static void __init msm7x2x_map_io(void)
  3948. {
  3949.     msm_map_common_io();
  3950.     msm_msm7x2x_allocate_memory_regions();
  3951.  
  3952. #if 0
  3953. #ifdef CONFIG_CACHE_L2X0
  3954.     if (machine_is_msm7x27_surf() || machine_is_msm7x27_ffa() || machine_is_blade()) {
  3955.         /* 7x27 has 256KB L2 cache:
  3956.             64Kb/Way and 4-Way Associativity;
  3957.             R/W latency: 3 cycles;
  3958.             evmon/parity/share disabled. */
  3959.         l2x0_init(MSM_L2CC_BASE, 0x00068012, 0xfe000000);
  3960.     }
  3961.    
  3962. #endif
  3963. #endif
  3964. #ifdef CONFIG_CACHE_L2X0
  3965.     l2x0_init(MSM_L2CC_BASE, 0x00068012, 0xfe000000);
  3966. #endif
  3967. }
  3968.  
  3969. //ruanmeisi
  3970. #ifdef CONFIG_ZTE_PLATFORM
  3971.  
  3972. #define ATAG_ZTEFTM 0x5d53cd73
  3973. static int  parse_tag_zteftm(const struct tag *tags)
  3974. {
  3975.         int flag = 0, find = 0;
  3976.         struct tag *t = (struct tag *)tags;
  3977.  
  3978.         for (; t->hdr.size; t = tag_next(t)) {
  3979.                 if (t->hdr.tag == ATAG_ZTEFTM) {
  3980.                         printk(KERN_DEBUG "find the zte ftm tag\n");
  3981.                         find = 1;
  3982.                         break;
  3983.                 }
  3984.         }
  3985.  
  3986.         if (find)
  3987.                 flag = t->u.revision.rev;
  3988.         printk(KERN_INFO "[ZYF@FTM]parse_tag_zteftm: zte FTM %s !\n",
  3989.            flag?"enable":"disable");
  3990.         return flag;
  3991. }
  3992.  
  3993. static void __init zte_fixup(struct machine_desc *desc, struct tag *tags,
  3994.                  char **cmdline, struct meminfo *mi)
  3995. {
  3996.         g_zte_ftm_flag_fixup = parse_tag_zteftm((const struct tag *)tags);
  3997.  
  3998. }
  3999.  
  4000. int get_ftm_from_tag(void)
  4001. {
  4002.     return g_zte_ftm_flag_fixup;
  4003. }
  4004. EXPORT_SYMBOL(get_ftm_from_tag);
  4005.  
  4006. #endif
  4007. //end
  4008.  
  4009. MACHINE_START(MSM7X27_SURF, "QCT MSM7x27 SURF")
  4010. #ifdef CONFIG_MSM_DEBUG_UART
  4011.     .phys_io        = MSM_DEBUG_UART_PHYS,
  4012.     .io_pg_offst    = ((MSM_DEBUG_UART_BASE) >> 18) & 0xfffc,
  4013. #endif
  4014.     .boot_params    = PHYS_OFFSET + 0x100,
  4015.     .map_io     = msm7x2x_map_io,
  4016.     .init_irq   = msm7x2x_init_irq,
  4017.     .init_machine   = msm7x2x_init,
  4018.     .timer      = &msm_timer,
  4019. MACHINE_END
  4020.  
  4021. MACHINE_START(MSM7X27_FFA, "QCT MSM7x27 FFA")
  4022. #ifdef CONFIG_MSM_DEBUG_UART
  4023.     .phys_io        = MSM_DEBUG_UART_PHYS,
  4024.     .io_pg_offst    = ((MSM_DEBUG_UART_BASE) >> 18) & 0xfffc,
  4025. #endif
  4026.     .boot_params    = PHYS_OFFSET + 0x100,
  4027.     .map_io     = msm7x2x_map_io,
  4028.     .init_irq   = msm7x2x_init_irq,
  4029.     .init_machine   = msm7x2x_init,
  4030.     .timer      = &msm_timer,
  4031. MACHINE_END
  4032.  
  4033. MACHINE_START(MSM7X25_SURF, "QCT MSM7x25 SURF")
  4034. #ifdef CONFIG_MSM_DEBUG_UART
  4035.     .phys_io        = MSM_DEBUG_UART_PHYS,
  4036.     .io_pg_offst    = ((MSM_DEBUG_UART_BASE) >> 18) & 0xfffc,
  4037. #endif
  4038.     .boot_params    = PHYS_OFFSET + 0x100,
  4039.     .map_io     = msm7x2x_map_io,
  4040.     .init_irq   = msm7x2x_init_irq,
  4041.     .init_machine   = msm7x2x_init,
  4042.     .timer      = &msm_timer,
  4043. MACHINE_END
  4044.  
  4045. MACHINE_START(MSM7X25_FFA, "QCT MSM7x25 FFA")
  4046. #ifdef CONFIG_MSM_DEBUG_UART
  4047.     .phys_io        = MSM_DEBUG_UART_PHYS,
  4048.     .io_pg_offst    = ((MSM_DEBUG_UART_BASE) >> 18) & 0xfffc,
  4049. #endif
  4050.     .boot_params    = PHYS_OFFSET + 0x100,
  4051.     .map_io     = msm7x2x_map_io,
  4052.     .init_irq   = msm7x2x_init_irq,
  4053.     .init_machine   = msm7x2x_init,
  4054.     .timer      = &msm_timer,
  4055. MACHINE_END
  4056.  
  4057. MACHINE_START(ROAMER, "roamer")
  4058. #ifdef CONFIG_MSM_DEBUG_UART
  4059.     .phys_io        = MSM_DEBUG_UART_PHYS,
  4060.     .io_pg_offst    = ((MSM_DEBUG_UART_BASE) >> 18) & 0xfffc,
  4061. #endif
  4062.     .boot_params    = PHYS_OFFSET + 0x100,
  4063. #ifdef CONFIG_ZTE_PLATFORM
  4064.   .fixup          = zte_fixup,
  4065. #endif
  4066.     .map_io     = msm7x2x_map_io,
  4067.     .init_irq   = msm7x2x_init_irq,
  4068.     .init_machine   = msm7x2x_init,
  4069.     .timer      = &msm_timer,
  4070. MACHINE_END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement