Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <linux/i2c.h>
- #include <linux/i2c/sx150x.h>
- #include <linux/gpio.h>
- #include <linux/kernel.h>
- #include <linux/platform_device.h>
- #include <asm/mach-types.h>
- #include <mach/msm_iomap.h>
- #include <mach/board.h>
- #include <mach/irqs-7xxx.h>
- #include "devices-msm7x2xa.h"
- #include "board-msm7627a.h"
- #ifdef CONFIG_TOUCHSCREEN_MXT224
- //#include <linux/atmel_maxtouch.h>
- #include <linux/input/atmel_qt602240.h>
- //extern struct atmel_i2c_platform_data atmel_data;
- #endif
- #ifdef CONFIG_TOUCHSCREEN_SYNAPTICS
- #include <linux/input/synaptics_rmi.h>
- #endif
- #ifdef CONFIG_TOUCHSCREEN_FOCALTECH
- #include <linux/input/focaltech_ft5x0x.h>
- #endif
- //
- // touchscreen gpio definition
- //
- #if defined (CONFIG_MACH_ATLAS40)
- #define GPIO_7X27A_TS_IRQ 82
- #define GPIO_7X27A_TS_EN 13
- #define GPIO_7X27A_TS_RST 12
- #elif defined (CONFIG_MACH_NICE) || defined (CONFIG_MACH_SEANPLUS)
- #define GPIO_7X27A_TS_IRQ 82
- #define GPIO_7X27A_TS_EN 13
- #define GPIO_7X27A_TS_RST 12
- #elif defined (CONFIG_MACH_ROAMER2)
- #define GPIO_7X27A_TS_IRQ 82
- #define GPIO_7X27A_TS_EN 107
- #define GPIO_7X27A_TS_RST 12//actually none
- #endif
- //
- // touchscreen firmware file name
- //
- #if defined (CONFIG_MACH_ATLAS40) // p740a
- #define FTC_FW_NAME "Ver11_20120409_N880E_9980_ID0x57_ATLAS40_app.bin"
- //#define SYN_FW_NAME "PR1101200-s2202_zte_30303039-ATLAS40-truly.img"
- #define SYN_FW_NAME "ATLAS40_PR1115996-s2202_Truly_32323038.img"
- #define ATM_FW_NAME ""
- #elif defined (CONFIG_MACH_NICE) //P752T
- //#define FTC_FW_NAME "Ver15_20120206_035_9920_ID0x57_roamer2_app.bin"
- #define FTC_FW_NAME "Ver17_20121018_035_9920_ID0x57_app.bin"
- #define SYN_FW_NAME "TM2346-P752T-LEAD_PR1197429-s2200_31353033.img"
- #define ATM_FW_NAME ""
- #elif defined (CONFIG_MACH_SEANPLUS) //P765U10(N850L)
- #define FTC_FW_NAME ""
- //#define SYN_FW_NAME "N850L_TRULY_PR1228845_31323036.img"
- #define SYN_FW_NAME "20121025_N850L_TRULY_PR1228845_31323039.img"
- #define ATM_FW_NAME ""
- #elif defined (CONFIG_MACH_ROAMER2)//P752D01 V790
- //#define FTC_FW_NAME "Ver15_20120206_035_9920_ID0x57_roamer2_app.bin"
- #define FTC_FW_NAME "Ver17_20121018_035_9920_ID0x57_app.bin"
- #define SYN_FW_NAME "ROAMER2_PR1108473_S2200_ZTE_bigthumb_31333038.img"
- #define ATM_FW_NAME ""
- #else
- #define FTC_FW_NAME ""
- #define SYN_FW_NAME ""
- #define ATM_FW_NAME ""
- #endif
- //
- // touchscreen virtual key definition
- //
- #ifdef CONFIG_TOUCHSCREEN_VIRTUAL_KEYS
- //#define CAP_TS_VKEY_CYPRESS "virtualkeys.cyttsp-i2c"
- #define CAP_TS_VKEY_SYNAPTICS "virtualkeys.syna-touchscreen"
- #define CAP_TS_VKEY_ATMEL "virtualkeys.atmel-touchscreen"
- #define CAP_TS_VKEY_FTS "virtualkeys.Fts-touchscreen"
- // board atlas40
- #if defined (CONFIG_MACH_ATLAS40)
- #define SYNAPTICS_MAX_Y_POSITION 1747
- static ssize_t cap_ts_vkeys_show(struct device *dev, struct device_attribute *attr, char *buf)
- {
- //printk("%s, %s\n",__func__,attr->attr.name);
- return sprintf(
- buf,__stringify(EV_KEY) ":" __stringify(KEY_MENU) ":45:850:100:60"
- ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":175:850:100:60"
- ":" __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":306:850:100:60"
- ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":437:850:100:60"
- "\n");
- }
- // board nice
- #elif defined (CONFIG_MACH_NICE)
- #define SYNAPTICS_MAX_Y_POSITION 1478//1602
- static ssize_t cap_ts_vkeys_show(struct device *dev, struct device_attribute *attr, char *buf)
- {
- //printk("%s, %s\n",__func__,attr->attr.name);
- return sprintf(
- buf,__stringify(EV_KEY) ":" __stringify(KEY_HOME) ":45:520:50:50"
- ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":120:520:60:50"
- ":" __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":200:520:60:50"
- ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":265:520:60:50"
- "\n");
- }
- #elif defined(CONFIG_MACH_SEANPLUS) //N850L (P765U10) 320*480 BACK HOME MENU
- /*ergate-009*/
- #define SYNAPTICS_MAX_Y_POSITION 1478//the y cord. read from ic is 1628
- static ssize_t cap_ts_vkeys_show(struct device *dev, struct device_attribute *attr, char *buf)
- {
- //printk("%s, %s\n",__func__,attr->attr.name);
- return sprintf(
- buf,__stringify(EV_KEY) ":" __stringify(KEY_BACK) ":46:520:50:50"
- ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":150:520:60:50"
- ":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":270:520:60:50"
- "\n");
- }
- #elif defined (CONFIG_MACH_ROAMER2)//P752D01 V790 320*480 MENU HOME BACK SEARCH
- #define SYNAPTICS_MAX_Y_POSITION 1478//1602
- static ssize_t cap_ts_vkeys_show(struct device *dev, struct device_attribute *attr, char *buf)
- {
- //printk("%s, %s\n",__func__,attr->attr.name);
- return sprintf(
- buf,__stringify(EV_KEY) ":" __stringify(KEY_MENU) ":45:520:50:50"
- ":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":120:520:60:50"
- ":" __stringify(EV_KEY) ":" __stringify(KEY_BACK) ":200:520:60:50"
- ":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":265:520:50:50"
- "\n");
- }
- #endif
- static struct device_attribute cap_ts_device_attr[] = {
- #if defined(CONFIG_TOUCHSCREEN_FOCALTECH)
- {
- .attr = {
- .name = CAP_TS_VKEY_FTS,
- .mode = S_IRUGO,
- },
- .show = &cap_ts_vkeys_show,
- .store = NULL,
- },
- #endif
- #if defined(CONFIG_TOUCHSCREEN_SYNAPTICS)
- {
- .attr = {
- .name = CAP_TS_VKEY_SYNAPTICS,
- .mode = S_IRUGO,
- },
- .show = &cap_ts_vkeys_show,
- .store = NULL,
- },
- #endif
- #if defined(CONFIG_TOUCHSCREEN_MXT224)
- {
- .attr = {
- .name = CAP_TS_VKEY_ATMEL,
- .mode = S_IRUGO,
- },
- .show = &cap_ts_vkeys_show,
- .store = NULL,
- },
- #endif
- };
- struct kobject *android_touch_kobj;
- static int cap_ts_vkeys_init(void)
- {
- int rc,i;
- struct kobject * cap_ts_properties_kobj=NULL;
- cap_ts_properties_kobj = kobject_create_and_add("board_properties", NULL);
- if (cap_ts_properties_kobj == NULL) {
- printk("%s: subsystem_register failed\n", __func__);
- rc = -ENOMEM;
- return rc;
- }
- android_touch_kobj = cap_ts_properties_kobj;
- for ( i=0; i < ARRAY_SIZE(cap_ts_device_attr); i++ ){
- rc = sysfs_create_file(cap_ts_properties_kobj, &cap_ts_device_attr[i].attr);
- if (rc) {
- printk("%s: sysfs_create_file failed\n", __func__);
- return rc;
- }
- }
- return 0;
- }
- #else
- #if defined(CONFIG_MACH_ATLAS40)
- #define SYNAPTICS_MAX_Y_POSITION 1747 //temp for p772a40
- #else
- #define SYNAPTICS_MAX_Y_POSITION 0
- #endif
- #endif
- static void touchscreen_irq( int hl, bool io_flag )
- {
- //io_flag: true- default input, false - output
- if ( io_flag == true )
- gpio_direction_input(GPIO_7X27A_TS_IRQ);
- else
- gpio_direction_output(GPIO_7X27A_TS_IRQ, hl);
- return;
- }
- static void touchscreen_reset( int hl )
- {
- gpio_direction_output(GPIO_7X27A_TS_RST, hl);
- return;
- }
- static void touchscreen_power(int on_off)
- {
- //pr_info("%s %d\n",__func__, on_off );
- if ( on_off == 1 )
- gpio_direction_output(GPIO_7X27A_TS_EN, 1);
- if ( on_off == 0 )
- gpio_direction_output(GPIO_7X27A_TS_EN,0);
- return;
- }
- static int touchscreen_gpio_init(int flag)
- {
- int ret = 0;
- //init
- if ( flag == 1 )
- {
- ret = gpio_request(GPIO_7X27A_TS_EN, "touch voltage");
- if ( ret ){
- pr_err("%s, gpio %d request failed!\n", __func__,GPIO_7X27A_TS_EN);
- return -1;
- }
- ret = gpio_request(GPIO_7X27A_TS_RST, "touch voltage");
- if (ret){
- pr_err("%s: gpio %d request is error!\n", __func__, GPIO_7X27A_TS_RST);
- return -1;
- }
- ret = gpio_request(GPIO_7X27A_TS_IRQ, "touch voltage");
- if (ret){
- pr_err("%s: gpio %d request is error!\n", __func__, GPIO_7X27A_TS_IRQ);
- return -1;
- }
- }
- //deinit
- if ( flag == 0)
- {
- gpio_free(GPIO_7X27A_TS_EN);
- gpio_free(GPIO_7X27A_TS_IRQ);
- gpio_free(GPIO_7X27A_TS_RST);
- }
- return 0;
- }
- //
- // i2c device definition
- //
- #if defined (CONFIG_TOUCHSCREEN_SYNAPTICS)
- static struct synaptics_rmi_data synaptics_ts_data = {
- .gpio_init = touchscreen_gpio_init,
- .power = touchscreen_power,
- .reset = touchscreen_reset,
- .irq = touchscreen_irq,
- .max_y_position = SYNAPTICS_MAX_Y_POSITION, // 0 - no vkey, do nothing
- .fwfile = SYN_FW_NAME,
- };
- #endif
- #if defined (CONFIG_TOUCHSCREEN_FOCALTECH)
- static struct focaltech_ts_platform_data focaltech_ts_data = {
- .gpio_init = touchscreen_gpio_init,
- .power = touchscreen_power,
- .reset = touchscreen_reset,
- .irq = touchscreen_irq,
- .fwfile = FTC_FW_NAME,
- };
- #endif
- #if defined (CONFIG_TOUCHSCREEN_MXT224)
- static struct atmel_platform_data atmel_ts_data = {
- .gpio_init = touchscreen_gpio_init,
- .power = touchscreen_power,
- .reset = touchscreen_reset,
- .irq = touchscreen_irq,
- .fwfile = ATM_FW_NAME,
- };
- #endif
- static struct i2c_board_info i2c_touch_devices[] = {
- #ifdef CONFIG_TOUCHSCREEN_FOCALTECH
- {
- I2C_BOARD_INFO("ft5x0x_ts", 0x3E ),
- .irq = MSM_GPIO_TO_INT(GPIO_7X27A_TS_IRQ),
- .platform_data = &focaltech_ts_data,
- },
- #endif
- #ifdef CONFIG_TOUCHSCREEN_SYNAPTICS
- {
- I2C_BOARD_INFO("syna-touchscreen", 0x22 ),
- .irq = MSM_GPIO_TO_INT(GPIO_7X27A_TS_IRQ),
- .platform_data = &synaptics_ts_data,
- },
- #endif
- #ifdef CONFIG_TOUCHSCREEN_MXT224
- {
- I2C_BOARD_INFO("atmel_qt602240", 0x4a ),
- .platform_data = &atmel_ts_data,
- .irq = MSM_GPIO_TO_INT(GPIO_7X27A_TS_IRQ),
- },
- #endif
- };
- void __init msm7x27a_ts_init(void)
- {
- #ifdef CONFIG_TOUCHSCREEN_VIRTUAL_KEYS
- cap_ts_vkeys_init();
- #endif
- i2c_register_board_info(MSM_GSBI1_QUP_I2C_BUS_ID,
- i2c_touch_devices,
- ARRAY_SIZE(i2c_touch_devices));
- return ;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement