Advertisement
Pteridium

kernel 3.0.8 roamer2 definitions

Feb 23rd, 2015
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 9.27 KB | None | 0 0
  1. #include <linux/i2c.h>
  2. #include <linux/i2c/sx150x.h>
  3. #include <linux/gpio.h>
  4. #include <linux/kernel.h>
  5. #include <linux/platform_device.h>
  6. #include <asm/mach-types.h>
  7. #include <mach/msm_iomap.h>
  8. #include <mach/board.h>
  9. #include <mach/irqs-7xxx.h>
  10. #include "devices-msm7x2xa.h"
  11. #include "board-msm7627a.h"
  12.  
  13.  
  14.  
  15. #ifdef CONFIG_TOUCHSCREEN_MXT224
  16. //#include <linux/atmel_maxtouch.h>
  17. #include <linux/input/atmel_qt602240.h>
  18. //extern struct atmel_i2c_platform_data atmel_data;
  19. #endif
  20. #ifdef CONFIG_TOUCHSCREEN_SYNAPTICS
  21. #include <linux/input/synaptics_rmi.h>
  22. #endif
  23. #ifdef CONFIG_TOUCHSCREEN_FOCALTECH
  24. #include <linux/input/focaltech_ft5x0x.h>
  25. #endif
  26.  
  27.  
  28.  
  29.  
  30. //
  31. //  touchscreen gpio definition
  32. //
  33. #if defined (CONFIG_MACH_ATLAS40)
  34. #define GPIO_7X27A_TS_IRQ       82
  35. #define GPIO_7X27A_TS_EN        13
  36. #define GPIO_7X27A_TS_RST       12
  37. #elif defined (CONFIG_MACH_NICE) || defined (CONFIG_MACH_SEANPLUS)
  38. #define GPIO_7X27A_TS_IRQ       82
  39. #define GPIO_7X27A_TS_EN        13
  40. #define GPIO_7X27A_TS_RST       12
  41. #elif defined (CONFIG_MACH_ROAMER2)
  42. #define GPIO_7X27A_TS_IRQ       82
  43. #define GPIO_7X27A_TS_EN        107
  44. #define GPIO_7X27A_TS_RST       12//actually none
  45. #endif
  46.  
  47.  
  48. //
  49. //  touchscreen firmware file name
  50. //
  51. #if defined (CONFIG_MACH_ATLAS40)   // p740a
  52. #define FTC_FW_NAME "Ver11_20120409_N880E_9980_ID0x57_ATLAS40_app.bin"
  53. //#define SYN_FW_NAME "PR1101200-s2202_zte_30303039-ATLAS40-truly.img"
  54. #define SYN_FW_NAME "ATLAS40_PR1115996-s2202_Truly_32323038.img"
  55. #define ATM_FW_NAME ""
  56. #elif defined (CONFIG_MACH_NICE) //P752T
  57. //#define FTC_FW_NAME "Ver15_20120206_035_9920_ID0x57_roamer2_app.bin"
  58. #define FTC_FW_NAME "Ver17_20121018_035_9920_ID0x57_app.bin"
  59. #define SYN_FW_NAME "TM2346-P752T-LEAD_PR1197429-s2200_31353033.img"
  60. #define ATM_FW_NAME ""
  61. #elif defined (CONFIG_MACH_SEANPLUS) //P765U10(N850L)
  62. #define FTC_FW_NAME ""
  63. //#define SYN_FW_NAME "N850L_TRULY_PR1228845_31323036.img"
  64. #define SYN_FW_NAME "20121025_N850L_TRULY_PR1228845_31323039.img"
  65. #define ATM_FW_NAME ""
  66. #elif defined (CONFIG_MACH_ROAMER2)//P752D01  V790
  67. //#define FTC_FW_NAME "Ver15_20120206_035_9920_ID0x57_roamer2_app.bin"
  68. #define FTC_FW_NAME "Ver17_20121018_035_9920_ID0x57_app.bin"
  69. #define SYN_FW_NAME "ROAMER2_PR1108473_S2200_ZTE_bigthumb_31333038.img"
  70. #define ATM_FW_NAME ""
  71. #else
  72. #define FTC_FW_NAME ""
  73. #define SYN_FW_NAME ""
  74. #define ATM_FW_NAME ""
  75. #endif
  76.  
  77.  
  78.  
  79. //
  80. //  touchscreen virtual key definition
  81. //
  82.  
  83. #ifdef CONFIG_TOUCHSCREEN_VIRTUAL_KEYS
  84. //#define CAP_TS_VKEY_CYPRESS "virtualkeys.cyttsp-i2c"
  85. #define CAP_TS_VKEY_SYNAPTICS "virtualkeys.syna-touchscreen"
  86. #define CAP_TS_VKEY_ATMEL "virtualkeys.atmel-touchscreen"
  87. #define CAP_TS_VKEY_FTS "virtualkeys.Fts-touchscreen"
  88.  
  89. // board atlas40
  90. #if defined (CONFIG_MACH_ATLAS40)
  91. #define SYNAPTICS_MAX_Y_POSITION    1747
  92. static ssize_t cap_ts_vkeys_show(struct device *dev,    struct device_attribute *attr, char *buf)
  93. {
  94.     //printk("%s, %s\n",__func__,attr->attr.name);
  95.     return sprintf(
  96.         buf,__stringify(EV_KEY) ":" __stringify(KEY_MENU) ":45:850:100:60"
  97.         ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":175:850:100:60"
  98.         ":" __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":306:850:100:60"
  99.         ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":437:850:100:60"
  100.         "\n");
  101. }
  102.  
  103. // board nice
  104. #elif defined (CONFIG_MACH_NICE)
  105. #define SYNAPTICS_MAX_Y_POSITION    1478//1602
  106. static ssize_t cap_ts_vkeys_show(struct device *dev,    struct device_attribute *attr, char *buf)
  107. {
  108.     //printk("%s, %s\n",__func__,attr->attr.name);
  109.     return sprintf(
  110.         buf,__stringify(EV_KEY) ":" __stringify(KEY_HOME) ":45:520:50:50"
  111.         ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":120:520:60:50"
  112.         ":" __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":200:520:60:50"
  113.         ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":265:520:60:50"
  114.         "\n"); 
  115. }
  116. #elif defined(CONFIG_MACH_SEANPLUS) //N850L (P765U10)  320*480   BACK HOME MENU
  117. /*ergate-009*/
  118. #define SYNAPTICS_MAX_Y_POSITION    1478//the y cord. read from ic is 1628
  119. static ssize_t cap_ts_vkeys_show(struct device *dev,    struct device_attribute *attr, char *buf)
  120. {
  121.     //printk("%s, %s\n",__func__,attr->attr.name);
  122.     return sprintf(
  123.         buf,__stringify(EV_KEY) ":" __stringify(KEY_BACK) ":46:520:50:50"
  124.         ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":150:520:60:50"
  125.         ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":270:520:60:50"
  126.         "\n"); 
  127. }
  128. #elif defined (CONFIG_MACH_ROAMER2)//P752D01  V790  320*480       MENU HOME BACK SEARCH
  129. #define SYNAPTICS_MAX_Y_POSITION    1478//1602
  130. static ssize_t cap_ts_vkeys_show(struct device *dev,    struct device_attribute *attr, char *buf)
  131. {
  132.     //printk("%s, %s\n",__func__,attr->attr.name);
  133.     return sprintf(
  134.         buf,__stringify(EV_KEY) ":" __stringify(KEY_MENU) ":45:520:50:50"
  135.         ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":120:520:60:50"
  136.         ":" __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":200:520:60:50"
  137.         ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":265:520:50:50"
  138.         "\n"); 
  139. }
  140. #endif
  141.  
  142.  
  143. static struct device_attribute cap_ts_device_attr[] = {
  144. #if defined(CONFIG_TOUCHSCREEN_FOCALTECH)
  145.     {
  146.         .attr = {
  147.             .name = CAP_TS_VKEY_FTS,
  148.             .mode = S_IRUGO,
  149.         },
  150.         .show   = &cap_ts_vkeys_show,
  151.         .store  = NULL,
  152.     },
  153. #endif
  154. #if defined(CONFIG_TOUCHSCREEN_SYNAPTICS)
  155. {
  156.     .attr = {
  157.         .name = CAP_TS_VKEY_SYNAPTICS,
  158.         .mode = S_IRUGO,
  159.     },
  160.     .show   = &cap_ts_vkeys_show,
  161.     .store  = NULL,
  162. },
  163. #endif
  164. #if defined(CONFIG_TOUCHSCREEN_MXT224)
  165.     {
  166.         .attr = {
  167.             .name = CAP_TS_VKEY_ATMEL,
  168.             .mode = S_IRUGO,
  169.         },
  170.         .show   = &cap_ts_vkeys_show,
  171.         .store  = NULL,
  172.     },
  173. #endif
  174. };
  175.  
  176. struct kobject *android_touch_kobj;
  177. static int cap_ts_vkeys_init(void)
  178. {
  179.     int rc,i;
  180.     struct kobject * cap_ts_properties_kobj=NULL;
  181.  
  182.     cap_ts_properties_kobj = kobject_create_and_add("board_properties", NULL);
  183.     if (cap_ts_properties_kobj == NULL) {
  184.         printk("%s: subsystem_register failed\n", __func__);
  185.         rc = -ENOMEM;
  186.         return rc;
  187.     }
  188.     android_touch_kobj = cap_ts_properties_kobj;
  189.  
  190.     for ( i=0; i < ARRAY_SIZE(cap_ts_device_attr); i++ ){
  191.         rc = sysfs_create_file(cap_ts_properties_kobj, &cap_ts_device_attr[i].attr);
  192.         if (rc) {
  193.             printk("%s: sysfs_create_file failed\n", __func__);
  194.             return rc;
  195.         }
  196.     }
  197.  
  198.     return 0;
  199. }
  200. #else
  201.  
  202. #if defined(CONFIG_MACH_ATLAS40)
  203. #define SYNAPTICS_MAX_Y_POSITION    1747    //temp for p772a40
  204. #else
  205. #define SYNAPTICS_MAX_Y_POSITION    0
  206. #endif
  207.  
  208. #endif
  209.  
  210.  
  211.  
  212. static void touchscreen_irq( int hl, bool io_flag )
  213. {
  214.     //io_flag: true- default input, false - output
  215.  
  216.     if ( io_flag == true )
  217.         gpio_direction_input(GPIO_7X27A_TS_IRQ);
  218.     else
  219.         gpio_direction_output(GPIO_7X27A_TS_IRQ, hl);
  220.  
  221.     return;
  222. }
  223.  
  224. static void touchscreen_reset( int hl )
  225. {
  226.     gpio_direction_output(GPIO_7X27A_TS_RST, hl);
  227.     return;
  228. }
  229.  
  230. static void touchscreen_power(int on_off)
  231. {
  232.     //pr_info("%s %d\n",__func__, on_off );
  233.  
  234.     if ( on_off == 1 )
  235.         gpio_direction_output(GPIO_7X27A_TS_EN, 1);
  236.  
  237.     if ( on_off == 0 )
  238.         gpio_direction_output(GPIO_7X27A_TS_EN,0);
  239.  
  240.     return;
  241. }
  242. static int touchscreen_gpio_init(int flag)
  243. {
  244.     int ret = 0;
  245.  
  246.     //init
  247.     if ( flag == 1 )
  248.     {
  249.         ret = gpio_request(GPIO_7X27A_TS_EN, "touch voltage");
  250.         if ( ret ){
  251.             pr_err("%s, gpio %d request failed!\n", __func__,GPIO_7X27A_TS_EN);
  252.             return -1;
  253.         }
  254.  
  255.         ret = gpio_request(GPIO_7X27A_TS_RST, "touch voltage");
  256.         if (ret){
  257.             pr_err("%s: gpio %d request is error!\n", __func__, GPIO_7X27A_TS_RST);
  258.             return -1;
  259.         }
  260.  
  261.         ret = gpio_request(GPIO_7X27A_TS_IRQ, "touch voltage");
  262.         if (ret){
  263.             pr_err("%s: gpio %d request is error!\n", __func__, GPIO_7X27A_TS_IRQ);
  264.             return -1;
  265.         }
  266.     }
  267.  
  268.     //deinit
  269.     if ( flag == 0)
  270.     {
  271.         gpio_free(GPIO_7X27A_TS_EN);
  272.         gpio_free(GPIO_7X27A_TS_IRQ);
  273.         gpio_free(GPIO_7X27A_TS_RST);
  274.     }
  275.  
  276.     return 0;
  277.  
  278. }
  279.  
  280.  
  281. //
  282. // i2c device definition
  283. //
  284.  
  285. #if defined (CONFIG_TOUCHSCREEN_SYNAPTICS)
  286. static struct synaptics_rmi_data synaptics_ts_data = {
  287.     .gpio_init = touchscreen_gpio_init,
  288.     .power  = touchscreen_power,
  289.     .reset  = touchscreen_reset,
  290.     .irq    = touchscreen_irq,
  291.     .max_y_position = SYNAPTICS_MAX_Y_POSITION, // 0 - no vkey, do nothing
  292.     .fwfile = SYN_FW_NAME,
  293. };
  294. #endif
  295.  
  296. #if defined (CONFIG_TOUCHSCREEN_FOCALTECH)
  297. static struct focaltech_ts_platform_data focaltech_ts_data = {
  298.     .gpio_init = touchscreen_gpio_init,
  299.     .power  = touchscreen_power,
  300.     .reset  = touchscreen_reset,
  301.     .irq    = touchscreen_irq,
  302.     .fwfile = FTC_FW_NAME,
  303. };
  304. #endif
  305.  
  306. #if defined (CONFIG_TOUCHSCREEN_MXT224)
  307. static struct atmel_platform_data atmel_ts_data = {
  308.     .gpio_init = touchscreen_gpio_init,
  309.     .power  = touchscreen_power,
  310.     .reset  = touchscreen_reset,
  311.     .irq    = touchscreen_irq,
  312.     .fwfile = ATM_FW_NAME,
  313. };
  314. #endif
  315.  
  316.  
  317. static struct i2c_board_info i2c_touch_devices[] = {
  318. #ifdef CONFIG_TOUCHSCREEN_FOCALTECH
  319.     {              
  320.         I2C_BOARD_INFO("ft5x0x_ts", 0x3E ),
  321.         .irq = MSM_GPIO_TO_INT(GPIO_7X27A_TS_IRQ),
  322.         .platform_data = &focaltech_ts_data,
  323.     }, 
  324. #endif
  325. #ifdef CONFIG_TOUCHSCREEN_SYNAPTICS
  326.     {
  327.         I2C_BOARD_INFO("syna-touchscreen", 0x22 ),
  328.         .irq = MSM_GPIO_TO_INT(GPIO_7X27A_TS_IRQ),
  329.         .platform_data = &synaptics_ts_data,
  330.     },
  331. #endif
  332. #ifdef CONFIG_TOUCHSCREEN_MXT224
  333.     {    
  334.         I2C_BOARD_INFO("atmel_qt602240", 0x4a ),
  335.         .platform_data = &atmel_ts_data,
  336.         .irq = MSM_GPIO_TO_INT(GPIO_7X27A_TS_IRQ),
  337.     },  
  338. #endif
  339. };
  340.  
  341.  
  342. void __init msm7x27a_ts_init(void)
  343. {
  344.  
  345. #ifdef CONFIG_TOUCHSCREEN_VIRTUAL_KEYS
  346.     cap_ts_vkeys_init();
  347. #endif
  348.  
  349.     i2c_register_board_info(MSM_GSBI1_QUP_I2C_BUS_ID,
  350.             i2c_touch_devices,
  351.             ARRAY_SIZE(i2c_touch_devices));
  352.  
  353.     return ;
  354. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement