rk3066 add phone pad modem support
[firefly-linux-kernel-4.4.55.git] / drivers / input / touchscreen / ct36x_ts / allwinner.c
1
2 #include <linux/i2c.h>
3
4 #include "tscore.h"
5 //#include "generic.h"
6
7
8
9 static struct i2c_device_id ct36x_ts_id[] = {
10         { DRIVER_NAME, 0 },
11         { }
12 };
13
14 static struct i2c_board_info i2c_board_info[] = {
15         {
16                 I2C_BOARD_INFO(DRIVER_NAME, 0x01),
17                 .platform_data = NULL,
18         },
19 };
20
21 struct i2c_driver ct36x_ts_driver  = {
22         .driver = {
23                 .owner  = THIS_MODULE,
24                 .name   = DRIVER_NAME
25         },
26         .id_table       = ct36x_ts_id,
27         .probe      = ct36x_ts_probe,
28         .suspend        = ct36x_ts_suspend,
29         .resume     = ct36x_ts_resume,
30         .remove         = __devexit_p(ct36x_ts_remove),
31 };
32
33 void ct36x_platform_get_cfg(struct ct36x_ts_info *ct36x_ts)
34 {
35         /* I2C config */
36         ct36x_ts->i2c_bus = CT36X_TS_I2C_BUS;
37         ct36x_ts->i2c_address = CT36X_TS_I2C_ADDRESS;
38
39         /* GPIO config */
40         ct36x_ts->rst = CT36X_TS_RST_PIN;
41         ct36x_ts->ss = CT36X_TS_IRQ_PIN;
42
43         /* IRQ config*/
44         ct36x_ts->irq = gpio_to_irq(ct36x_ts->ss);
45
46         ct36x_ts->ready = 0;
47 }
48
49 int ct36x_platform_set_dev(struct ct36x_ts_info *ct36x_ts)
50 {
51         struct i2c_adapter *adapter;
52         struct i2c_client *client;
53
54         adapter = i2c_get_adapter(ct36x_ts->i2c_bus);
55         if ( !adapter ) {
56                 printk("Unable to get i2c adapter on bus %d.\n", ct36x_ts->i2c_bus);
57                 return -ENODEV;
58         }
59
60         client = i2c_new_device(adapter, i2c_board_info);
61         i2c_put_adapter(adapter);
62         if (!client) {
63                 printk("Unable to create i2c device on bus %d.\n", ct36x_ts->i2c_bus);
64                 return -ENODEV;
65         }
66
67         ct36x_ts->client = client;
68         i2c_set_clientdata(client, ct36x_ts);
69
70         return 0;
71 }
72
73 int ct36x_platform_get_resource(struct ct36x_ts_info *ct36x_ts)
74 {
75         int err = -1;
76
77         // Init Reset pin
78         err = gpio_request(ct36x_ts->rst, "ct36x_ts_rst");
79         if ( err ) {
80                 return -EIO;
81         }
82         gpio_direction_output(ct36x_ts->rst, 1);
83         gpio_set_value(ct36x_ts->rst, 1);
84
85         // Init Int pin
86         err = gpio_request(ct36x_ts->ss, "ct36x_ts_int");
87         if ( err ) {
88                 return -EIO;
89         }
90         gpio_direction_input(ct36x_ts->ss);
91
92         return 0;
93 }
94
95 void ct36x_platform_put_resource(struct ct36x_ts_info *ct36x_ts)
96 {
97         gpio_free(ct36x_ts->rst);
98         gpio_free(ct36x_ts->ss);
99 }