Skip to content

Commit 71749f5

Browse files
Iiro Valkonendtor
authored andcommitted
Input: atmel_mxt_ts - allow board code to suppliy controller config
As there is no common configuration settings that would work in every situation, remove the fixed config data from driver code and add config data to platform data. Signed-off-by: Iiro Valkonen <iiro.valkonen@atmel.com> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
1 parent 46ee2a0 commit 71749f5

2 files changed

Lines changed: 18 additions & 135 deletions

File tree

‎drivers/input/touchscreen/atmel_mxt_ts.c‎

Lines changed: 13 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -199,122 +199,6 @@
199199

200200
#define MXT_MAX_FINGER 10
201201

202-
/* Initial register values recommended from chip vendor */
203-
static const u8 init_vals_ver_20[] = {
204-
/* MXT_GEN_COMMAND(6) */
205-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
206-
/* MXT_GEN_POWER(7) */
207-
0x20, 0xff, 0x32,
208-
/* MXT_GEN_ACQUIRE(8) */
209-
0x08, 0x05, 0x05, 0x00, 0x00, 0x00, 0x05, 0x14,
210-
/* MXT_TOUCH_MULTI(9) */
211-
0x00, 0x00, 0x00, 0x11, 0x0a, 0x00, 0x00, 0x00, 0x02, 0x00,
212-
0x00, 0x01, 0x01, 0x0e, 0x0a, 0x0a, 0x0a, 0x0a, 0x00, 0x00,
213-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0x64,
214-
/* MXT_TOUCH_KEYARRAY(15) */
215-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
216-
0x00,
217-
/* MXT_SPT_GPIOPWM(19) */
218-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
219-
0x00, 0x00,
220-
/* MXT_PROCI_GRIPFACE(20) */
221-
0x00, 0x64, 0x64, 0x64, 0x64, 0x00, 0x00, 0x1e, 0x14, 0x04,
222-
0x1e, 0x00,
223-
/* MXT_PROCG_NOISE(22) */
224-
0x05, 0x00, 0x00, 0x19, 0x00, 0xe7, 0xff, 0x04, 0x32, 0x00,
225-
0x01, 0x0a, 0x0f, 0x14, 0x00, 0x00, 0xe8,
226-
/* MXT_TOUCH_PROXIMITY(23) */
227-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
228-
0x00, 0x00, 0x00,
229-
/* MXT_PROCI_ONETOUCH(24) */
230-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
231-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
232-
/* MXT_SPT_SELFTEST(25) */
233-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
234-
0x00, 0x00, 0x00, 0x00,
235-
/* MXT_PROCI_TWOTOUCH(27) */
236-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
237-
/* MXT_SPT_CTECONFIG(28) */
238-
0x00, 0x00, 0x00, 0x04, 0x08,
239-
};
240-
241-
static const u8 init_vals_ver_21[] = {
242-
/* MXT_GEN_COMMAND(6) */
243-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
244-
/* MXT_GEN_POWER(7) */
245-
0x20, 0xff, 0x32,
246-
/* MXT_GEN_ACQUIRE(8) */
247-
0x0a, 0x00, 0x05, 0x00, 0x00, 0x00, 0x09, 0x23,
248-
/* MXT_TOUCH_MULTI(9) */
249-
0x00, 0x00, 0x00, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x02, 0x00,
250-
0x00, 0x01, 0x01, 0x0e, 0x0a, 0x0a, 0x0a, 0x0a, 0x00, 0x00,
251-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
252-
/* MXT_TOUCH_KEYARRAY(15) */
253-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
254-
0x00,
255-
/* MXT_SPT_GPIOPWM(19) */
256-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
257-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
258-
/* MXT_PROCI_GRIPFACE(20) */
259-
0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x28, 0x04,
260-
0x0f, 0x0a,
261-
/* MXT_PROCG_NOISE(22) */
262-
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x23, 0x00,
263-
0x00, 0x05, 0x0f, 0x19, 0x23, 0x2d, 0x03,
264-
/* MXT_TOUCH_PROXIMITY(23) */
265-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
266-
0x00, 0x00, 0x00,
267-
/* MXT_PROCI_ONETOUCH(24) */
268-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
269-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
270-
/* MXT_SPT_SELFTEST(25) */
271-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
272-
0x00, 0x00, 0x00, 0x00,
273-
/* MXT_PROCI_TWOTOUCH(27) */
274-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
275-
/* MXT_SPT_CTECONFIG(28) */
276-
0x00, 0x00, 0x00, 0x08, 0x10, 0x00,
277-
};
278-
279-
static const u8 init_vals_ver_22[] = {
280-
/* MXT_GEN_COMMAND(6) */
281-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
282-
/* MXT_GEN_POWER(7) */
283-
0x20, 0xff, 0x32,
284-
/* MXT_GEN_ACQUIRE(8) */
285-
0x0a, 0x00, 0x05, 0x00, 0x00, 0x00, 0x09, 0x23,
286-
/* MXT_TOUCH_MULTI(9) */
287-
0x00, 0x00, 0x00, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x02, 0x00,
288-
0x00, 0x01, 0x01, 0x0e, 0x0a, 0x0a, 0x0a, 0x0a, 0x00, 0x00,
289-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
290-
0x00,
291-
/* MXT_TOUCH_KEYARRAY(15) */
292-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
293-
0x00,
294-
/* MXT_SPT_GPIOPWM(19) */
295-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
296-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
297-
/* MXT_PROCI_GRIPFACE(20) */
298-
0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x28, 0x04,
299-
0x0f, 0x0a,
300-
/* MXT_PROCG_NOISE(22) */
301-
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x23, 0x00,
302-
0x00, 0x05, 0x0f, 0x19, 0x23, 0x2d, 0x03,
303-
/* MXT_TOUCH_PROXIMITY(23) */
304-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
305-
0x00, 0x00, 0x00, 0x00, 0x00,
306-
/* MXT_PROCI_ONETOUCH(24) */
307-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
308-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
309-
/* MXT_SPT_SELFTEST(25) */
310-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
311-
0x00, 0x00, 0x00, 0x00,
312-
/* MXT_PROCI_TWOTOUCH(27) */
313-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
314-
/* MXT_SPT_CTECONFIG(28) */
315-
0x00, 0x00, 0x00, 0x08, 0x10, 0x00,
316-
};
317-
318202
struct mxt_info {
319203
u8 family_id;
320204
u8 variant_id;
@@ -714,26 +598,15 @@ static irqreturn_t mxt_interrupt(int irq, void *dev_id)
714598

715599
static int mxt_check_reg_init(struct mxt_data *data)
716600
{
601+
const struct mxt_platform_data *pdata = data->pdata;
717602
struct mxt_object *object;
718603
struct device *dev = &data->client->dev;
719604
int index = 0;
720-
int i, j;
721-
u8 version = data->info.version;
722-
u8 *init_vals;
605+
int i, j, config_offset;
723606

724-
switch (version) {
725-
case MXT_VER_20:
726-
init_vals = (u8 *)init_vals_ver_20;
727-
break;
728-
case MXT_VER_21:
729-
init_vals = (u8 *)init_vals_ver_21;
730-
break;
731-
case MXT_VER_22:
732-
init_vals = (u8 *)init_vals_ver_22;
733-
break;
734-
default:
735-
dev_err(dev, "Firmware version %d doesn't support\n", version);
736-
return -EINVAL;
607+
if (!pdata->config) {
608+
dev_dbg(dev, "No cfg data defined, skipping reg init\n");
609+
return 0;
737610
}
738611

739612
for (i = 0; i < data->info.object_num; i++) {
@@ -742,10 +615,15 @@ static int mxt_check_reg_init(struct mxt_data *data)
742615
if (!mxt_object_writable(object->type))
743616
continue;
744617

745-
for (j = 0; j < object->size + 1; j++)
618+
for (j = 0; j < object->size + 1; j++) {
619+
config_offset = index + j;
620+
if (config_offset > pdata->config_length) {
621+
dev_err(dev, "Not enough config data!\n");
622+
return -EINVAL;
623+
}
746624
mxt_write_object(data, object->type, j,
747-
init_vals[index + j]);
748-
625+
pdata->config[config_offset]);
626+
}
749627
index += object->size + 1;
750628
}
751629

‎include/linux/i2c/atmel_mxt_ts.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#ifndef __LINUX_ATMEL_MXT_TS_H
1414
#define __LINUX_ATMEL_MXT_TS_H
1515

16+
#include <linux/types.h>
17+
1618
/* Orient */
1719
#define MXT_NORMAL 0x0
1820
#define MXT_DIAGONAL 0x1
@@ -25,6 +27,9 @@
2527

2628
/* The platform data for the Atmel maXTouch touchscreen driver */
2729
struct mxt_platform_data {
30+
const u8 *config;
31+
size_t config_length;
32+
2833
unsigned int x_line;
2934
unsigned int y_line;
3035
unsigned int x_size;

0 commit comments

Comments
 (0)