10f382cadSJob Noorman // SPDX-License-Identifier: GPL-2.0-only
20f382cadSJob Noorman /*
30f382cadSJob Noorman * Driver for Himax hx83112b touchscreens
40f382cadSJob Noorman *
50f382cadSJob Noorman * Copyright (C) 2022 Job Noorman <job@noorman.info>
60f382cadSJob Noorman *
75e91cef9SFelix Kaechele * HX83100A support
85e91cef9SFelix Kaechele * Copyright (C) 2024 Felix Kaechele <felix@kaechele.ca>
95e91cef9SFelix Kaechele *
100f382cadSJob Noorman * This code is based on "Himax Android Driver Sample Code for QCT platform":
110f382cadSJob Noorman *
120f382cadSJob Noorman * Copyright (C) 2017 Himax Corporation.
130f382cadSJob Noorman */
140f382cadSJob Noorman
150f382cadSJob Noorman #include <linux/delay.h>
160f382cadSJob Noorman #include <linux/err.h>
170f382cadSJob Noorman #include <linux/gpio/consumer.h>
180f382cadSJob Noorman #include <linux/i2c.h>
190f382cadSJob Noorman #include <linux/input.h>
200f382cadSJob Noorman #include <linux/input/mt.h>
210f382cadSJob Noorman #include <linux/input/touchscreen.h>
220f382cadSJob Noorman #include <linux/interrupt.h>
230f382cadSJob Noorman #include <linux/kernel.h>
240f382cadSJob Noorman #include <linux/regmap.h>
250f382cadSJob Noorman
260f382cadSJob Noorman #define HIMAX_MAX_POINTS 10
270f382cadSJob Noorman
2805eab545SFelix Kaechele #define HIMAX_AHB_ADDR_BYTE_0 0x00
2905eab545SFelix Kaechele #define HIMAX_AHB_ADDR_RDATA_BYTE_0 0x08
3005eab545SFelix Kaechele #define HIMAX_AHB_ADDR_ACCESS_DIRECTION 0x0c
310944829dSFelix Kaechele #define HIMAX_AHB_ADDR_INCR4 0x0d
320944829dSFelix Kaechele #define HIMAX_AHB_ADDR_CONTI 0x13
3305eab545SFelix Kaechele #define HIMAX_AHB_ADDR_EVENT_STACK 0x30
340f382cadSJob Noorman
3505eab545SFelix Kaechele #define HIMAX_AHB_CMD_ACCESS_DIRECTION_READ 0x00
360944829dSFelix Kaechele #define HIMAX_AHB_CMD_INCR4 0x10
370944829dSFelix Kaechele #define HIMAX_AHB_CMD_CONTI 0x31
3805eab545SFelix Kaechele
3905eab545SFelix Kaechele #define HIMAX_REG_ADDR_ICID 0x900000d0
400f382cadSJob Noorman
415e91cef9SFelix Kaechele #define HX83100A_REG_FW_EVENT_STACK 0x90060000
425e91cef9SFelix Kaechele
430f382cadSJob Noorman #define HIMAX_INVALID_COORD 0xffff
440f382cadSJob Noorman
450f382cadSJob Noorman struct himax_event_point {
460f382cadSJob Noorman __be16 x;
470f382cadSJob Noorman __be16 y;
480f382cadSJob Noorman } __packed;
490f382cadSJob Noorman
500f382cadSJob Noorman struct himax_event {
510f382cadSJob Noorman struct himax_event_point points[HIMAX_MAX_POINTS];
520f382cadSJob Noorman u8 majors[HIMAX_MAX_POINTS];
530f382cadSJob Noorman u8 pad0[2];
540f382cadSJob Noorman u8 num_points;
550f382cadSJob Noorman u8 pad1[2];
560f382cadSJob Noorman u8 checksum_fix;
570f382cadSJob Noorman } __packed;
580f382cadSJob Noorman
590f382cadSJob Noorman static_assert(sizeof(struct himax_event) == 56);
600f382cadSJob Noorman
61aa9007edSFelix Kaechele struct himax_ts_data;
62aa9007edSFelix Kaechele struct himax_chip {
63aa9007edSFelix Kaechele u32 id;
64aa9007edSFelix Kaechele int (*check_id)(struct himax_ts_data *ts);
65aa9007edSFelix Kaechele int (*read_events)(struct himax_ts_data *ts, struct himax_event *event,
66aa9007edSFelix Kaechele size_t length);
67aa9007edSFelix Kaechele };
68aa9007edSFelix Kaechele
690f382cadSJob Noorman struct himax_ts_data {
70aa9007edSFelix Kaechele const struct himax_chip *chip;
710f382cadSJob Noorman struct gpio_desc *gpiod_rst;
720f382cadSJob Noorman struct input_dev *input_dev;
730f382cadSJob Noorman struct i2c_client *client;
740f382cadSJob Noorman struct regmap *regmap;
750f382cadSJob Noorman struct touchscreen_properties props;
760f382cadSJob Noorman };
770f382cadSJob Noorman
780f382cadSJob Noorman static const struct regmap_config himax_regmap_config = {
790f382cadSJob Noorman .reg_bits = 8,
800f382cadSJob Noorman .val_bits = 32,
810f382cadSJob Noorman .val_format_endian = REGMAP_ENDIAN_LITTLE,
820f382cadSJob Noorman };
830f382cadSJob Noorman
himax_bus_enable_burst(struct himax_ts_data * ts)840944829dSFelix Kaechele static int himax_bus_enable_burst(struct himax_ts_data *ts)
850f382cadSJob Noorman {
860f382cadSJob Noorman int error;
870f382cadSJob Noorman
880944829dSFelix Kaechele error = regmap_write(ts->regmap, HIMAX_AHB_ADDR_CONTI,
890944829dSFelix Kaechele HIMAX_AHB_CMD_CONTI);
900944829dSFelix Kaechele if (error)
910944829dSFelix Kaechele return error;
920944829dSFelix Kaechele
930944829dSFelix Kaechele error = regmap_write(ts->regmap, HIMAX_AHB_ADDR_INCR4,
940944829dSFelix Kaechele HIMAX_AHB_CMD_INCR4);
950944829dSFelix Kaechele if (error)
960944829dSFelix Kaechele return error;
970944829dSFelix Kaechele
980944829dSFelix Kaechele return 0;
990944829dSFelix Kaechele }
1000944829dSFelix Kaechele
himax_bus_read(struct himax_ts_data * ts,u32 address,void * dst,size_t length)1010944829dSFelix Kaechele static int himax_bus_read(struct himax_ts_data *ts, u32 address, void *dst,
1020944829dSFelix Kaechele size_t length)
1030944829dSFelix Kaechele {
1040944829dSFelix Kaechele int error;
1050944829dSFelix Kaechele
1060944829dSFelix Kaechele if (length > 4) {
1070944829dSFelix Kaechele error = himax_bus_enable_burst(ts);
1080944829dSFelix Kaechele if (error)
1090944829dSFelix Kaechele return error;
1100944829dSFelix Kaechele }
1110944829dSFelix Kaechele
11205eab545SFelix Kaechele error = regmap_write(ts->regmap, HIMAX_AHB_ADDR_BYTE_0, address);
1130f382cadSJob Noorman if (error)
1140f382cadSJob Noorman return error;
1150f382cadSJob Noorman
11605eab545SFelix Kaechele error = regmap_write(ts->regmap, HIMAX_AHB_ADDR_ACCESS_DIRECTION,
11705eab545SFelix Kaechele HIMAX_AHB_CMD_ACCESS_DIRECTION_READ);
1180f382cadSJob Noorman if (error)
1190f382cadSJob Noorman return error;
1200f382cadSJob Noorman
1210944829dSFelix Kaechele if (length > 4)
1220944829dSFelix Kaechele error = regmap_noinc_read(ts->regmap, HIMAX_AHB_ADDR_RDATA_BYTE_0,
1230944829dSFelix Kaechele dst, length);
1240944829dSFelix Kaechele else
1250944829dSFelix Kaechele error = regmap_read(ts->regmap, HIMAX_AHB_ADDR_RDATA_BYTE_0,
1260944829dSFelix Kaechele dst);
1270944829dSFelix Kaechele if (error)
1280944829dSFelix Kaechele return error;
1290944829dSFelix Kaechele
1300944829dSFelix Kaechele return 0;
1310944829dSFelix Kaechele }
1320944829dSFelix Kaechele
himax_reset(struct himax_ts_data * ts)1330f382cadSJob Noorman static void himax_reset(struct himax_ts_data *ts)
1340f382cadSJob Noorman {
1350f382cadSJob Noorman gpiod_set_value_cansleep(ts->gpiod_rst, 1);
1360f382cadSJob Noorman
1370f382cadSJob Noorman /* Delay copied from downstream driver */
1380f382cadSJob Noorman msleep(20);
1390f382cadSJob Noorman gpiod_set_value_cansleep(ts->gpiod_rst, 0);
1400f382cadSJob Noorman
1410f382cadSJob Noorman /*
1420f382cadSJob Noorman * The downstream driver doesn't contain this delay but is seems safer
1430f382cadSJob Noorman * to include it. The range is just a guess that seems to work well.
1440f382cadSJob Noorman */
1450f382cadSJob Noorman usleep_range(1000, 1100);
1460f382cadSJob Noorman }
1470f382cadSJob Noorman
himax_read_product_id(struct himax_ts_data * ts,u32 * product_id)1480f382cadSJob Noorman static int himax_read_product_id(struct himax_ts_data *ts, u32 *product_id)
1490f382cadSJob Noorman {
1500f382cadSJob Noorman int error;
1510f382cadSJob Noorman
152*4e870e6bSDmitry Torokhov error = himax_bus_read(ts, HIMAX_REG_ADDR_ICID, product_id,
153*4e870e6bSDmitry Torokhov sizeof(*product_id));
1540f382cadSJob Noorman if (error)
1550f382cadSJob Noorman return error;
1560f382cadSJob Noorman
1570f382cadSJob Noorman *product_id >>= 8;
1580f382cadSJob Noorman return 0;
1590f382cadSJob Noorman }
1600f382cadSJob Noorman
himax_check_product_id(struct himax_ts_data * ts)1610f382cadSJob Noorman static int himax_check_product_id(struct himax_ts_data *ts)
1620f382cadSJob Noorman {
1630f382cadSJob Noorman int error;
1640f382cadSJob Noorman u32 product_id;
1650f382cadSJob Noorman
1660f382cadSJob Noorman error = himax_read_product_id(ts, &product_id);
1670f382cadSJob Noorman if (error)
1680f382cadSJob Noorman return error;
1690f382cadSJob Noorman
1700f382cadSJob Noorman dev_dbg(&ts->client->dev, "Product id: %x\n", product_id);
1710f382cadSJob Noorman
172aa9007edSFelix Kaechele if (product_id == ts->chip->id)
1730f382cadSJob Noorman return 0;
1740f382cadSJob Noorman
175aa9007edSFelix Kaechele dev_err(&ts->client->dev, "Unknown product id: %x\n",
176aa9007edSFelix Kaechele product_id);
1770f382cadSJob Noorman return -EINVAL;
1780f382cadSJob Noorman }
1790f382cadSJob Noorman
himax_input_register(struct himax_ts_data * ts)1800f382cadSJob Noorman static int himax_input_register(struct himax_ts_data *ts)
1810f382cadSJob Noorman {
1820f382cadSJob Noorman int error;
1830f382cadSJob Noorman
1840f382cadSJob Noorman ts->input_dev = devm_input_allocate_device(&ts->client->dev);
1850f382cadSJob Noorman if (!ts->input_dev) {
1860f382cadSJob Noorman dev_err(&ts->client->dev, "Failed to allocate input device\n");
1870f382cadSJob Noorman return -ENOMEM;
1880f382cadSJob Noorman }
1890f382cadSJob Noorman
1900f382cadSJob Noorman ts->input_dev->name = "Himax Touchscreen";
1910f382cadSJob Noorman
1920f382cadSJob Noorman input_set_capability(ts->input_dev, EV_ABS, ABS_MT_POSITION_X);
1930f382cadSJob Noorman input_set_capability(ts->input_dev, EV_ABS, ABS_MT_POSITION_Y);
1940f382cadSJob Noorman input_set_abs_params(ts->input_dev, ABS_MT_WIDTH_MAJOR, 0, 200, 0, 0);
1950f382cadSJob Noorman input_set_abs_params(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0, 200, 0, 0);
1960f382cadSJob Noorman
1970f382cadSJob Noorman touchscreen_parse_properties(ts->input_dev, true, &ts->props);
1980f382cadSJob Noorman
1990f382cadSJob Noorman error = input_mt_init_slots(ts->input_dev, HIMAX_MAX_POINTS,
2000f382cadSJob Noorman INPUT_MT_DIRECT | INPUT_MT_DROP_UNUSED);
2010f382cadSJob Noorman if (error) {
2020f382cadSJob Noorman dev_err(&ts->client->dev,
2030f382cadSJob Noorman "Failed to initialize MT slots: %d\n", error);
2040f382cadSJob Noorman return error;
2050f382cadSJob Noorman }
2060f382cadSJob Noorman
2070f382cadSJob Noorman error = input_register_device(ts->input_dev);
2080f382cadSJob Noorman if (error) {
2090f382cadSJob Noorman dev_err(&ts->client->dev,
2100f382cadSJob Noorman "Failed to register input device: %d\n", error);
2110f382cadSJob Noorman return error;
2120f382cadSJob Noorman }
2130f382cadSJob Noorman
2140f382cadSJob Noorman return 0;
2150f382cadSJob Noorman }
2160f382cadSJob Noorman
himax_event_get_num_points(const struct himax_event * event)2170f382cadSJob Noorman static u8 himax_event_get_num_points(const struct himax_event *event)
2180f382cadSJob Noorman {
2190f382cadSJob Noorman if (event->num_points == 0xff)
2200f382cadSJob Noorman return 0;
2210f382cadSJob Noorman else
2220f382cadSJob Noorman return event->num_points & 0x0f;
2230f382cadSJob Noorman }
2240f382cadSJob Noorman
himax_process_event_point(struct himax_ts_data * ts,const struct himax_event * event,int point_index)2250f382cadSJob Noorman static bool himax_process_event_point(struct himax_ts_data *ts,
2260f382cadSJob Noorman const struct himax_event *event,
2270f382cadSJob Noorman int point_index)
2280f382cadSJob Noorman {
2290f382cadSJob Noorman const struct himax_event_point *point = &event->points[point_index];
2300f382cadSJob Noorman u16 x = be16_to_cpu(point->x);
2310f382cadSJob Noorman u16 y = be16_to_cpu(point->y);
2320f382cadSJob Noorman u8 w = event->majors[point_index];
2330f382cadSJob Noorman
2340f382cadSJob Noorman if (x == HIMAX_INVALID_COORD || y == HIMAX_INVALID_COORD)
2350f382cadSJob Noorman return false;
2360f382cadSJob Noorman
2370f382cadSJob Noorman input_mt_slot(ts->input_dev, point_index);
2380f382cadSJob Noorman input_mt_report_slot_state(ts->input_dev, MT_TOOL_FINGER, true);
2390f382cadSJob Noorman touchscreen_report_pos(ts->input_dev, &ts->props, x, y, true);
2400f382cadSJob Noorman input_report_abs(ts->input_dev, ABS_MT_TOUCH_MAJOR, w);
2410f382cadSJob Noorman input_report_abs(ts->input_dev, ABS_MT_WIDTH_MAJOR, w);
2420f382cadSJob Noorman return true;
2430f382cadSJob Noorman }
2440f382cadSJob Noorman
himax_process_event(struct himax_ts_data * ts,const struct himax_event * event)2450f382cadSJob Noorman static void himax_process_event(struct himax_ts_data *ts,
2460f382cadSJob Noorman const struct himax_event *event)
2470f382cadSJob Noorman {
2480f382cadSJob Noorman int i;
2490f382cadSJob Noorman int num_points_left = himax_event_get_num_points(event);
2500f382cadSJob Noorman
2510f382cadSJob Noorman for (i = 0; i < HIMAX_MAX_POINTS && num_points_left > 0; i++) {
2520f382cadSJob Noorman if (himax_process_event_point(ts, event, i))
2530f382cadSJob Noorman num_points_left--;
2540f382cadSJob Noorman }
2550f382cadSJob Noorman
2560f382cadSJob Noorman input_mt_sync_frame(ts->input_dev);
2570f382cadSJob Noorman input_sync(ts->input_dev);
2580f382cadSJob Noorman }
2590f382cadSJob Noorman
himax_verify_checksum(struct himax_ts_data * ts,const struct himax_event * event)2600f382cadSJob Noorman static bool himax_verify_checksum(struct himax_ts_data *ts,
2610f382cadSJob Noorman const struct himax_event *event)
2620f382cadSJob Noorman {
2630f382cadSJob Noorman u8 *data = (u8 *)event;
2640f382cadSJob Noorman int i;
2650f382cadSJob Noorman u16 checksum = 0;
2660f382cadSJob Noorman
2670f382cadSJob Noorman for (i = 0; i < sizeof(*event); i++)
2680f382cadSJob Noorman checksum += data[i];
2690f382cadSJob Noorman
2700f382cadSJob Noorman if ((checksum & 0x00ff) != 0) {
2710f382cadSJob Noorman dev_err(&ts->client->dev, "Wrong event checksum: %04x\n",
2720f382cadSJob Noorman checksum);
2730f382cadSJob Noorman return false;
2740f382cadSJob Noorman }
2750f382cadSJob Noorman
2760f382cadSJob Noorman return true;
2770f382cadSJob Noorman }
2780f382cadSJob Noorman
himax_read_events(struct himax_ts_data * ts,struct himax_event * event,size_t length)279aa9007edSFelix Kaechele static int himax_read_events(struct himax_ts_data *ts,
280aa9007edSFelix Kaechele struct himax_event *event, size_t length)
281aa9007edSFelix Kaechele {
282aa9007edSFelix Kaechele return regmap_raw_read(ts->regmap, HIMAX_AHB_ADDR_EVENT_STACK, event,
283aa9007edSFelix Kaechele length);
284aa9007edSFelix Kaechele }
285aa9007edSFelix Kaechele
hx83100a_read_events(struct himax_ts_data * ts,struct himax_event * event,size_t length)2865e91cef9SFelix Kaechele static int hx83100a_read_events(struct himax_ts_data *ts,
2875e91cef9SFelix Kaechele struct himax_event *event, size_t length)
2885e91cef9SFelix Kaechele {
2895e91cef9SFelix Kaechele return himax_bus_read(ts, HX83100A_REG_FW_EVENT_STACK, event, length);
2905e91cef9SFelix Kaechele };
2915e91cef9SFelix Kaechele
himax_handle_input(struct himax_ts_data * ts)2920f382cadSJob Noorman static int himax_handle_input(struct himax_ts_data *ts)
2930f382cadSJob Noorman {
2940f382cadSJob Noorman int error;
2950f382cadSJob Noorman struct himax_event event;
2960f382cadSJob Noorman
297aa9007edSFelix Kaechele error = ts->chip->read_events(ts, &event, sizeof(event));
2980f382cadSJob Noorman if (error) {
2990f382cadSJob Noorman dev_err(&ts->client->dev, "Failed to read input event: %d\n",
3000f382cadSJob Noorman error);
3010f382cadSJob Noorman return error;
3020f382cadSJob Noorman }
3030f382cadSJob Noorman
3040f382cadSJob Noorman /*
3050f382cadSJob Noorman * Only process the current event when it has a valid checksum but
3060f382cadSJob Noorman * don't consider it a fatal error when it doesn't.
3070f382cadSJob Noorman */
3080f382cadSJob Noorman if (himax_verify_checksum(ts, &event))
3090f382cadSJob Noorman himax_process_event(ts, &event);
3100f382cadSJob Noorman
3110f382cadSJob Noorman return 0;
3120f382cadSJob Noorman }
3130f382cadSJob Noorman
himax_irq_handler(int irq,void * dev_id)3140f382cadSJob Noorman static irqreturn_t himax_irq_handler(int irq, void *dev_id)
3150f382cadSJob Noorman {
3160f382cadSJob Noorman int error;
3170f382cadSJob Noorman struct himax_ts_data *ts = dev_id;
3180f382cadSJob Noorman
3190f382cadSJob Noorman error = himax_handle_input(ts);
3200f382cadSJob Noorman if (error)
3210f382cadSJob Noorman return IRQ_NONE;
3220f382cadSJob Noorman
3230f382cadSJob Noorman return IRQ_HANDLED;
3240f382cadSJob Noorman }
3250f382cadSJob Noorman
himax_probe(struct i2c_client * client)3264d1c7cc6SUwe Kleine-König static int himax_probe(struct i2c_client *client)
3270f382cadSJob Noorman {
3280f382cadSJob Noorman int error;
3290f382cadSJob Noorman struct device *dev = &client->dev;
3300f382cadSJob Noorman struct himax_ts_data *ts;
3310f382cadSJob Noorman
3320f382cadSJob Noorman if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
3330f382cadSJob Noorman dev_err(dev, "I2C check functionality failed\n");
3340f382cadSJob Noorman return -ENXIO;
3350f382cadSJob Noorman }
3360f382cadSJob Noorman
3370f382cadSJob Noorman ts = devm_kzalloc(dev, sizeof(*ts), GFP_KERNEL);
3380f382cadSJob Noorman if (!ts)
3390f382cadSJob Noorman return -ENOMEM;
3400f382cadSJob Noorman
3410f382cadSJob Noorman i2c_set_clientdata(client, ts);
3420f382cadSJob Noorman ts->client = client;
343aa9007edSFelix Kaechele ts->chip = i2c_get_match_data(client);
3440f382cadSJob Noorman
3450f382cadSJob Noorman ts->regmap = devm_regmap_init_i2c(client, &himax_regmap_config);
3460f382cadSJob Noorman error = PTR_ERR_OR_ZERO(ts->regmap);
3470f382cadSJob Noorman if (error) {
3480f382cadSJob Noorman dev_err(dev, "Failed to initialize regmap: %d\n", error);
3490f382cadSJob Noorman return error;
3500f382cadSJob Noorman }
3510f382cadSJob Noorman
3520f382cadSJob Noorman ts->gpiod_rst = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
3530f382cadSJob Noorman error = PTR_ERR_OR_ZERO(ts->gpiod_rst);
3540f382cadSJob Noorman if (error) {
3550f382cadSJob Noorman dev_err(dev, "Failed to get reset GPIO: %d\n", error);
3560f382cadSJob Noorman return error;
3570f382cadSJob Noorman }
3580f382cadSJob Noorman
3590f382cadSJob Noorman himax_reset(ts);
3600f382cadSJob Noorman
361aa9007edSFelix Kaechele if (ts->chip->check_id) {
3620f382cadSJob Noorman error = himax_check_product_id(ts);
3630f382cadSJob Noorman if (error)
3640f382cadSJob Noorman return error;
365aa9007edSFelix Kaechele }
3660f382cadSJob Noorman
3670f382cadSJob Noorman error = himax_input_register(ts);
3680f382cadSJob Noorman if (error)
3690f382cadSJob Noorman return error;
3700f382cadSJob Noorman
3710f382cadSJob Noorman error = devm_request_threaded_irq(dev, client->irq, NULL,
3720f382cadSJob Noorman himax_irq_handler, IRQF_ONESHOT,
3730f382cadSJob Noorman client->name, ts);
3740f382cadSJob Noorman if (error)
3750f382cadSJob Noorman return error;
3760f382cadSJob Noorman
3770f382cadSJob Noorman return 0;
3780f382cadSJob Noorman }
3790f382cadSJob Noorman
himax_suspend(struct device * dev)3800f382cadSJob Noorman static int himax_suspend(struct device *dev)
3810f382cadSJob Noorman {
3820f382cadSJob Noorman struct himax_ts_data *ts = dev_get_drvdata(dev);
3830f382cadSJob Noorman
3840f382cadSJob Noorman disable_irq(ts->client->irq);
3850f382cadSJob Noorman return 0;
3860f382cadSJob Noorman }
3870f382cadSJob Noorman
himax_resume(struct device * dev)3880f382cadSJob Noorman static int himax_resume(struct device *dev)
3890f382cadSJob Noorman {
3900f382cadSJob Noorman struct himax_ts_data *ts = dev_get_drvdata(dev);
3910f382cadSJob Noorman
3920f382cadSJob Noorman enable_irq(ts->client->irq);
3930f382cadSJob Noorman return 0;
3940f382cadSJob Noorman }
3950f382cadSJob Noorman
3960f382cadSJob Noorman static DEFINE_SIMPLE_DEV_PM_OPS(himax_pm_ops, himax_suspend, himax_resume);
3970f382cadSJob Noorman
3985e91cef9SFelix Kaechele static const struct himax_chip hx83100a_chip = {
3995e91cef9SFelix Kaechele .read_events = hx83100a_read_events,
4005e91cef9SFelix Kaechele };
4015e91cef9SFelix Kaechele
402aa9007edSFelix Kaechele static const struct himax_chip hx83112b_chip = {
403aa9007edSFelix Kaechele .id = 0x83112b,
404aa9007edSFelix Kaechele .check_id = himax_check_product_id,
405aa9007edSFelix Kaechele .read_events = himax_read_events,
406aa9007edSFelix Kaechele };
407aa9007edSFelix Kaechele
4080f382cadSJob Noorman static const struct i2c_device_id himax_ts_id[] = {
4095e91cef9SFelix Kaechele { "hx83100a", (kernel_ulong_t)&hx83100a_chip },
410aa9007edSFelix Kaechele { "hx83112b", (kernel_ulong_t)&hx83112b_chip },
4110f382cadSJob Noorman { /* sentinel */ }
4120f382cadSJob Noorman };
4130f382cadSJob Noorman MODULE_DEVICE_TABLE(i2c, himax_ts_id);
4140f382cadSJob Noorman
4150f382cadSJob Noorman #ifdef CONFIG_OF
4160f382cadSJob Noorman static const struct of_device_id himax_of_match[] = {
4175e91cef9SFelix Kaechele { .compatible = "himax,hx83100a", .data = &hx83100a_chip },
418aa9007edSFelix Kaechele { .compatible = "himax,hx83112b", .data = &hx83112b_chip },
4190f382cadSJob Noorman { /* sentinel */ }
4200f382cadSJob Noorman };
4210f382cadSJob Noorman MODULE_DEVICE_TABLE(of, himax_of_match);
4220f382cadSJob Noorman #endif
4230f382cadSJob Noorman
4240f382cadSJob Noorman static struct i2c_driver himax_ts_driver = {
425d8bde56dSUwe Kleine-König .probe = himax_probe,
4260f382cadSJob Noorman .id_table = himax_ts_id,
4270f382cadSJob Noorman .driver = {
4280f382cadSJob Noorman .name = "Himax-hx83112b-TS",
4290f382cadSJob Noorman .of_match_table = of_match_ptr(himax_of_match),
4300f382cadSJob Noorman .pm = pm_sleep_ptr(&himax_pm_ops),
4310f382cadSJob Noorman },
4320f382cadSJob Noorman };
4330f382cadSJob Noorman module_i2c_driver(himax_ts_driver);
4340f382cadSJob Noorman
4350f382cadSJob Noorman MODULE_AUTHOR("Job Noorman <job@noorman.info>");
4360f382cadSJob Noorman MODULE_DESCRIPTION("Himax hx83112b touchscreen driver");
4370f382cadSJob Noorman MODULE_LICENSE("GPL");
438