Commit daf49728553077dd2098ac176c00090a3eb4b190
Committed by
Sekhar Nori
1 parent
834c2e12b7
Exists in
ti-lsk-linux-4.1.y
and in
5 other branches
Input: edt-ft5x06 - Add support for variable amount of max support points
Update code so that the maximum supported points aren't hard coded but can be changed. Set the maximum support points based on the data passed along side the compatible field. Signed-off-by: Franklin S Cooper Jr <fcooper@ti.com> Signed-off-by: Sekhar Nori <nsekhar@ti.com>
Showing 1 changed file with 49 additions and 10 deletions Side-by-side Diff
drivers/input/touchscreen/edt-ft5x06.c
... | ... | @@ -36,12 +36,11 @@ |
36 | 36 | #include <linux/slab.h> |
37 | 37 | #include <linux/gpio.h> |
38 | 38 | #include <linux/of_gpio.h> |
39 | +#include <linux/of_device.h> | |
39 | 40 | #include <linux/input/mt.h> |
40 | 41 | #include <linux/input/touchscreen.h> |
41 | 42 | #include <linux/input/edt-ft5x06.h> |
42 | 43 | |
43 | -#define MAX_SUPPORT_POINTS 5 | |
44 | - | |
45 | 44 | #define WORK_REGISTER_THRESHOLD 0x00 |
46 | 45 | #define WORK_REGISTER_REPORT_RATE 0x08 |
47 | 46 | #define WORK_REGISTER_GAIN 0x30 |
... | ... | @@ -107,6 +106,7 @@ |
107 | 106 | int gain; |
108 | 107 | int offset; |
109 | 108 | int report_rate; |
109 | + int max_support_points; | |
110 | 110 | |
111 | 111 | char name[EDT_NAME_LEN]; |
112 | 112 | |
... | ... | @@ -114,6 +114,10 @@ |
114 | 114 | enum edt_ver version; |
115 | 115 | }; |
116 | 116 | |
117 | +struct edt_i2c_chip_data { | |
118 | + int max_support_points; | |
119 | +}; | |
120 | + | |
117 | 121 | static int edt_ft5x06_ts_readwrite(struct i2c_client *client, |
118 | 122 | u16 wr_len, u8 *wr_buf, |
119 | 123 | u16 rd_len, u8 *rd_buf) |
120 | 124 | |
... | ... | @@ -182,14 +186,14 @@ |
182 | 186 | tplen = 4; /* data comes in so called frames */ |
183 | 187 | |
184 | 188 | /* how many bytes to listen for */ |
185 | - datalen = tplen * MAX_SUPPORT_POINTS + offset + 1; | |
189 | + datalen = tplen * tsdata->max_support_points + offset + 1; | |
186 | 190 | break; |
187 | 191 | |
188 | 192 | case M09: |
189 | 193 | cmd = 0x02; |
190 | 194 | offset = 1; |
191 | 195 | tplen = 6; |
192 | - datalen = tplen * MAX_SUPPORT_POINTS + 1 - cmd; | |
196 | + datalen = tplen * tsdata->max_support_points + 1 - cmd; | |
193 | 197 | break; |
194 | 198 | |
195 | 199 | default: |
... | ... | @@ -221,7 +225,7 @@ |
221 | 225 | goto out; |
222 | 226 | } |
223 | 227 | |
224 | - for (i = 0; i < MAX_SUPPORT_POINTS; i++) { | |
228 | + for (i = 0; i < tsdata->max_support_points; i++) { | |
225 | 229 | u8 *buf = &rdbuf[i * tplen + offset]; |
226 | 230 | bool down; |
227 | 231 | |
228 | 232 | |
... | ... | @@ -894,11 +898,39 @@ |
894 | 898 | } |
895 | 899 | } |
896 | 900 | |
901 | +#ifdef CONFIG_OF | |
902 | + | |
903 | +static const struct of_device_id edt_ft5x06_of_match[]; | |
904 | + | |
905 | +static void edt_ft5x06_ts_set_max_support_points(struct device *dev, | |
906 | + struct edt_ft5x06_ts_data *tsdata) | |
907 | +{ | |
908 | + struct edt_i2c_chip_data *chip_data; | |
909 | + const struct of_device_id *match; | |
910 | + | |
911 | + match = of_match_device(of_match_ptr(edt_ft5x06_of_match), dev); | |
912 | + | |
913 | + if (match) { | |
914 | + chip_data = (struct edt_i2c_chip_data *)match->data; | |
915 | + tsdata->max_support_points = chip_data->max_support_points; | |
916 | + } else { | |
917 | + tsdata->max_support_points = 5; | |
918 | + } | |
919 | + | |
920 | +} | |
921 | +#else | |
922 | +static void edt_ft5x06_ts_set_max_support_points(struct device *dev, | |
923 | + struct edt_ft5x06_ts_data *tsdata) | |
924 | +{ | |
925 | +} | |
926 | +#endif | |
927 | + | |
897 | 928 | static int edt_ft5x06_ts_probe(struct i2c_client *client, |
898 | 929 | const struct i2c_device_id *id) |
899 | 930 | { |
900 | 931 | const struct edt_ft5x06_platform_data *pdata = |
901 | 932 | dev_get_platdata(&client->dev); |
933 | + struct device *dev = &client->dev; | |
902 | 934 | struct edt_ft5x06_ts_data *tsdata; |
903 | 935 | struct input_dev *input; |
904 | 936 | int error; |
... | ... | @@ -913,6 +945,8 @@ |
913 | 945 | return -ENOMEM; |
914 | 946 | } |
915 | 947 | |
948 | + edt_ft5x06_ts_set_max_support_points(dev, tsdata); | |
949 | + | |
916 | 950 | gpio = devm_gpiod_get_optional(&client->dev, "reset", GPIOD_OUT_HIGH); |
917 | 951 | if (IS_ERR(gpio)) { |
918 | 952 | error = PTR_ERR(gpio); |
... | ... | @@ -1003,7 +1037,7 @@ |
1003 | 1037 | if (!pdata) |
1004 | 1038 | touchscreen_parse_properties(input, true); |
1005 | 1039 | |
1006 | - error = input_mt_init_slots(input, MAX_SUPPORT_POINTS, 0); | |
1040 | + error = input_mt_init_slots(input, tsdata->max_support_points, 0); | |
1007 | 1041 | if (error) { |
1008 | 1042 | dev_err(&client->dev, "Unable to init MT slots.\n"); |
1009 | 1043 | return error; |
1010 | 1044 | |
... | ... | @@ -1085,11 +1119,16 @@ |
1085 | 1119 | MODULE_DEVICE_TABLE(i2c, edt_ft5x06_ts_id); |
1086 | 1120 | |
1087 | 1121 | #ifdef CONFIG_OF |
1122 | + | |
1123 | +static const struct edt_i2c_chip_data edt_ft5x06_data = { | |
1124 | + .max_support_points = 5, | |
1125 | +}; | |
1126 | + | |
1088 | 1127 | static const struct of_device_id edt_ft5x06_of_match[] = { |
1089 | - { .compatible = "edt,edt-ft5206", }, | |
1090 | - { .compatible = "edt,edt-ft5306", }, | |
1091 | - { .compatible = "edt,edt-ft5406", }, | |
1092 | - { .compatible = "edt,edt-ft5506", }, | |
1128 | + { .compatible = "edt,edt-ft5206", .data = &edt_ft5x06_data}, | |
1129 | + { .compatible = "edt,edt-ft5306", .data = &edt_ft5x06_data}, | |
1130 | + { .compatible = "edt,edt-ft5406", .data = &edt_ft5x06_data}, | |
1131 | + { .compatible = "edt,edt-ft5506", .data = &edt_ft5x06_data}, | |
1093 | 1132 | { /* sentinel */ } |
1094 | 1133 | }; |
1095 | 1134 | MODULE_DEVICE_TABLE(of, edt_ft5x06_of_match); |