2 * MELFAS MIP4 Touchscreen
4 * Copyright (C) 2016 MELFAS Inc.
6 * Author : Sangwon Jee <jeesw@melfas.com>
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
19 #include <linux/acpi.h>
20 #include <linux/delay.h>
21 #include <linux/firmware.h>
22 #include <linux/gpio/consumer.h>
23 #include <linux/i2c.h>
24 #include <linux/input.h>
25 #include <linux/input/mt.h>
26 #include <linux/interrupt.h>
27 #include <linux/module.h>
29 #include <linux/slab.h>
30 #include <asm/unaligned.h>
32 #define MIP4_DEVICE_NAME "mip4_ts"
34 /*****************************************************************
36 * Version : MIP 4.0 Rev 4.6
37 *****************************************************************/
40 #define MIP4_R0_BOOT 0x00
41 #define MIP4_R1_BOOT_MODE 0x01
42 #define MIP4_R1_BOOT_BUF_ADDR 0x10
43 #define MIP4_R1_BOOT_STATUS 0x20
44 #define MIP4_R1_BOOT_CMD 0x30
45 #define MIP4_R1_BOOT_TARGET_ADDR 0x40
46 #define MIP4_R1_BOOT_SIZE 0x44
48 #define MIP4_R0_INFO 0x01
49 #define MIP4_R1_INFO_PRODUCT_NAME 0x00
50 #define MIP4_R1_INFO_RESOLUTION_X 0x10
51 #define MIP4_R1_INFO_RESOLUTION_Y 0x12
52 #define MIP4_R1_INFO_NODE_NUM_X 0x14
53 #define MIP4_R1_INFO_NODE_NUM_Y 0x15
54 #define MIP4_R1_INFO_KEY_NUM 0x16
55 #define MIP4_R1_INFO_PRESSURE_NUM 0x17
56 #define MIP4_R1_INFO_LENGTH_X 0x18
57 #define MIP4_R1_INFO_LENGTH_Y 0x1A
58 #define MIP4_R1_INFO_PPM_X 0x1C
59 #define MIP4_R1_INFO_PPM_Y 0x1D
60 #define MIP4_R1_INFO_VERSION_BOOT 0x20
61 #define MIP4_R1_INFO_VERSION_CORE 0x22
62 #define MIP4_R1_INFO_VERSION_APP 0x24
63 #define MIP4_R1_INFO_VERSION_PARAM 0x26
64 #define MIP4_R1_INFO_SECT_BOOT_START 0x30
65 #define MIP4_R1_INFO_SECT_BOOT_END 0x31
66 #define MIP4_R1_INFO_SECT_CORE_START 0x32
67 #define MIP4_R1_INFO_SECT_CORE_END 0x33
68 #define MIP4_R1_INFO_SECT_APP_START 0x34
69 #define MIP4_R1_INFO_SECT_APP_END 0x35
70 #define MIP4_R1_INFO_SECT_PARAM_START 0x36
71 #define MIP4_R1_INFO_SECT_PARAM_END 0x37
72 #define MIP4_R1_INFO_BUILD_DATE 0x40
73 #define MIP4_R1_INFO_BUILD_TIME 0x44
74 #define MIP4_R1_INFO_CHECKSUM_PRECALC 0x48
75 #define MIP4_R1_INFO_CHECKSUM_REALTIME 0x4A
76 #define MIP4_R1_INFO_PROTOCOL_NAME 0x50
77 #define MIP4_R1_INFO_PROTOCOL_VERSION 0x58
78 #define MIP4_R1_INFO_IC_ID 0x70
79 #define MIP4_R1_INFO_IC_NAME 0x71
80 #define MIP4_R1_INFO_IC_VENDOR_ID 0x75
81 #define MIP4_R1_INFO_IC_HW_CATEGORY 0x77
82 #define MIP4_R1_INFO_CONTACT_THD_SCR 0x78
83 #define MIP4_R1_INFO_CONTACT_THD_KEY 0x7A
85 #define MIP4_R0_EVENT 0x02
86 #define MIP4_R1_EVENT_SUPPORTED_FUNC 0x00
87 #define MIP4_R1_EVENT_FORMAT 0x04
88 #define MIP4_R1_EVENT_SIZE 0x06
89 #define MIP4_R1_EVENT_PACKET_INFO 0x10
90 #define MIP4_R1_EVENT_PACKET_DATA 0x11
92 #define MIP4_R0_CTRL 0x06
93 #define MIP4_R1_CTRL_READY_STATUS 0x00
94 #define MIP4_R1_CTRL_EVENT_READY 0x01
95 #define MIP4_R1_CTRL_MODE 0x10
96 #define MIP4_R1_CTRL_EVENT_TRIGGER_TYPE 0x11
97 #define MIP4_R1_CTRL_RECALIBRATE 0x12
98 #define MIP4_R1_CTRL_POWER_STATE 0x13
99 #define MIP4_R1_CTRL_GESTURE_TYPE 0x14
100 #define MIP4_R1_CTRL_DISABLE_ESD_ALERT 0x18
101 #define MIP4_R1_CTRL_CHARGER_MODE 0x19
102 #define MIP4_R1_CTRL_HIGH_SENS_MODE 0x1A
103 #define MIP4_R1_CTRL_WINDOW_MODE 0x1B
104 #define MIP4_R1_CTRL_PALM_REJECTION 0x1C
105 #define MIP4_R1_CTRL_EDGE_CORRECTION 0x1D
106 #define MIP4_R1_CTRL_ENTER_GLOVE_MODE 0x1E
107 #define MIP4_R1_CTRL_I2C_ON_LPM 0x1F
108 #define MIP4_R1_CTRL_GESTURE_DEBUG 0x20
109 #define MIP4_R1_CTRL_PALM_EVENT 0x22
110 #define MIP4_R1_CTRL_PROXIMITY_SENSING 0x23
113 #define MIP4_BOOT_MODE_BOOT 0x01
114 #define MIP4_BOOT_MODE_APP 0x02
116 #define MIP4_BOOT_STATUS_BUSY 0x05
117 #define MIP4_BOOT_STATUS_ERROR 0x0E
118 #define MIP4_BOOT_STATUS_DONE 0xA0
120 #define MIP4_BOOT_CMD_MASS_ERASE 0x15
121 #define MIP4_BOOT_CMD_PROGRAM 0x54
122 #define MIP4_BOOT_CMD_ERASE 0x8F
123 #define MIP4_BOOT_CMD_WRITE 0xA5
124 #define MIP4_BOOT_CMD_READ 0xC2
126 #define MIP4_EVENT_INPUT_TYPE_KEY 0
127 #define MIP4_EVENT_INPUT_TYPE_SCREEN 1
128 #define MIP4_EVENT_INPUT_TYPE_PROXIMITY 2
130 #define I2C_RETRY_COUNT 3 /* 2~ */
132 #define MIP4_BUF_SIZE 128
133 #define MIP4_MAX_FINGERS 10
134 #define MIP4_MAX_KEYS 4
136 #define MIP4_TOUCH_MAJOR_MIN 0
137 #define MIP4_TOUCH_MAJOR_MAX 255
138 #define MIP4_TOUCH_MINOR_MIN 0
139 #define MIP4_TOUCH_MINOR_MAX 255
140 #define MIP4_PRESSURE_MIN 0
141 #define MIP4_PRESSURE_MAX 255
143 #define MIP4_FW_NAME "melfas_mip4.fw"
144 #define MIP4_FW_UPDATE_DEBUG 0 /* 0 (default) or 1 */
146 struct mip4_fw_version
{
154 struct i2c_client
*client
;
155 struct input_dev
*input
;
156 struct gpio_desc
*gpio_ce
;
159 char product_name
[16];
170 struct mip4_fw_version fw_version
;
172 unsigned int event_size
;
173 unsigned int event_format
;
175 unsigned int key_num
;
176 unsigned short key_code
[MIP4_MAX_KEYS
];
178 bool wake_irq_enabled
;
180 u8 buf
[MIP4_BUF_SIZE
];
183 static int mip4_i2c_xfer(struct mip4_ts
*ts
,
184 char *write_buf
, unsigned int write_len
,
185 char *read_buf
, unsigned int read_len
)
187 struct i2c_msg msg
[] = {
189 .addr
= ts
->client
->addr
,
194 .addr
= ts
->client
->addr
,
200 int retry
= I2C_RETRY_COUNT
;
205 res
= i2c_transfer(ts
->client
->adapter
, msg
, ARRAY_SIZE(msg
));
206 if (res
== ARRAY_SIZE(msg
))
209 error
= res
< 0 ? res
: -EIO
;
210 dev_err(&ts
->client
->dev
,
211 "%s - i2c_transfer failed: %d (%d)\n",
212 __func__
, error
, res
);
218 static void mip4_parse_fw_version(const u8
*buf
, struct mip4_fw_version
*v
)
220 v
->boot
= get_unaligned_le16(buf
+ 0);
221 v
->core
= get_unaligned_le16(buf
+ 2);
222 v
->app
= get_unaligned_le16(buf
+ 4);
223 v
->param
= get_unaligned_le16(buf
+ 6);
227 * Read chip firmware version
229 static int mip4_get_fw_version(struct mip4_ts
*ts
)
231 u8 cmd
[] = { MIP4_R0_INFO
, MIP4_R1_INFO_VERSION_BOOT
};
232 u8 buf
[sizeof(ts
->fw_version
)];
235 error
= mip4_i2c_xfer(ts
, cmd
, sizeof(cmd
), buf
, sizeof(buf
));
237 memset(&ts
->fw_version
, 0xff, sizeof(ts
->fw_version
));
241 mip4_parse_fw_version(buf
, &ts
->fw_version
);
247 * Fetch device characteristics
249 static int mip4_query_device(struct mip4_ts
*ts
)
256 cmd
[0] = MIP4_R0_INFO
;
257 cmd
[1] = MIP4_R1_INFO_PRODUCT_NAME
;
258 error
= mip4_i2c_xfer(ts
, cmd
, sizeof(cmd
),
259 ts
->product_name
, sizeof(ts
->product_name
));
261 dev_warn(&ts
->client
->dev
,
262 "Failed to retrieve product name: %d\n", error
);
264 dev_dbg(&ts
->client
->dev
, "product name: %.*s\n",
265 (int)sizeof(ts
->product_name
), ts
->product_name
);
268 cmd
[0] = MIP4_R0_INFO
;
269 cmd
[1] = MIP4_R1_INFO_IC_NAME
;
270 error
= mip4_i2c_xfer(ts
, cmd
, sizeof(cmd
),
271 ts
->ic_name
, sizeof(ts
->ic_name
));
273 dev_warn(&ts
->client
->dev
,
274 "Failed to retrieve IC name: %d\n", error
);
276 dev_dbg(&ts
->client
->dev
, "IC name: %.*s\n",
277 (int)sizeof(ts
->ic_name
), ts
->ic_name
);
279 /* Firmware version */
280 error
= mip4_get_fw_version(ts
);
282 dev_warn(&ts
->client
->dev
,
283 "Failed to retrieve FW version: %d\n", error
);
285 dev_dbg(&ts
->client
->dev
, "F/W Version: %04X %04X %04X %04X\n",
286 ts
->fw_version
.boot
, ts
->fw_version
.core
,
287 ts
->fw_version
.app
, ts
->fw_version
.param
);
290 cmd
[0] = MIP4_R0_INFO
;
291 cmd
[1] = MIP4_R1_INFO_RESOLUTION_X
;
292 error
= mip4_i2c_xfer(ts
, cmd
, sizeof(cmd
), buf
, 14);
294 dev_warn(&ts
->client
->dev
,
295 "Failed to retrieve touchscreen parameters: %d\n",
298 ts
->max_x
= get_unaligned_le16(&buf
[0]);
299 ts
->max_y
= get_unaligned_le16(&buf
[2]);
300 dev_dbg(&ts
->client
->dev
, "max_x: %d, max_y: %d\n",
301 ts
->max_x
, ts
->max_y
);
305 ts
->node_key
= buf
[6];
306 dev_dbg(&ts
->client
->dev
,
307 "node_x: %d, node_y: %d, node_key: %d\n",
308 ts
->node_x
, ts
->node_y
, ts
->node_key
);
312 dev_dbg(&ts
->client
->dev
, "ppm_x: %d, ppm_y: %d\n",
313 ts
->ppm_x
, ts
->ppm_y
);
316 if (ts
->node_key
> 0)
317 ts
->key_num
= ts
->node_key
;
321 cmd
[0] = MIP4_R0_EVENT
;
322 cmd
[1] = MIP4_R1_EVENT_SUPPORTED_FUNC
;
323 error
= mip4_i2c_xfer(ts
, cmd
, sizeof(cmd
), buf
, 7);
325 dev_warn(&ts
->client
->dev
,
326 "Failed to retrieve device type: %d\n", error
);
327 ts
->event_format
= 0xff;
329 ts
->event_format
= get_unaligned_le16(&buf
[4]);
330 ts
->event_size
= buf
[6];
331 dev_dbg(&ts
->client
->dev
, "event_format: %d, event_size: %d\n",
332 ts
->event_format
, ts
->event_size
);
334 if (ts
->event_format
== 2 || ts
->event_format
> 3)
335 dev_warn(&ts
->client
->dev
,
336 "Unknown event format %d\n", ts
->event_format
);
342 static int mip4_power_on(struct mip4_ts
*ts
)
345 gpiod_set_value_cansleep(ts
->gpio_ce
, 1);
347 /* Booting delay : 200~300ms */
348 usleep_range(200 * 1000, 300 * 1000);
354 static void mip4_power_off(struct mip4_ts
*ts
)
357 gpiod_set_value_cansleep(ts
->gpio_ce
, 0);
361 * Clear touch input event status
363 static void mip4_clear_input(struct mip4_ts
*ts
)
368 for (i
= 0; i
< MIP4_MAX_FINGERS
; i
++) {
369 input_mt_slot(ts
->input
, i
);
370 input_mt_report_slot_state(ts
->input
, MT_TOOL_FINGER
, 0);
374 for (i
= 0; i
< ts
->key_num
; i
++)
375 input_report_key(ts
->input
, ts
->key_code
[i
], 0);
377 input_sync(ts
->input
);
380 static int mip4_enable(struct mip4_ts
*ts
)
384 error
= mip4_power_on(ts
);
388 enable_irq(ts
->client
->irq
);
393 static void mip4_disable(struct mip4_ts
*ts
)
395 disable_irq(ts
->client
->irq
);
399 mip4_clear_input(ts
);
402 /*****************************************************************
404 *****************************************************************/
406 static void mip4_report_keys(struct mip4_ts
*ts
, u8
*packet
)
411 switch (ts
->event_format
) {
414 key
= packet
[0] & 0x0F;
415 down
= packet
[0] & 0x80;
420 key
= packet
[0] & 0x0F;
421 down
= packet
[1] & 0x01;
425 /* Report key event */
426 if (key
>= 1 && key
<= ts
->key_num
) {
427 unsigned short keycode
= ts
->key_code
[key
- 1];
429 dev_dbg(&ts
->client
->dev
,
430 "Key - ID: %d, keycode: %d, state: %d\n",
433 input_event(ts
->input
, EV_MSC
, MSC_SCAN
, keycode
);
434 input_report_key(ts
->input
, keycode
, down
);
437 dev_err(&ts
->client
->dev
, "Unknown key: %d\n", key
);
441 static void mip4_report_touch(struct mip4_ts
*ts
, u8
*packet
)
448 u8 pressure_stage
= 0;
454 switch (ts
->event_format
) {
458 state
= packet
[0] & BIT(7);
459 hover
= packet
[0] & BIT(5);
460 palm
= packet
[0] & BIT(4);
461 id
= (packet
[0] & 0x0F) - 1;
462 x
= ((packet
[1] & 0x0F) << 8) | packet
[2];
463 y
= (((packet
[1] >> 4) & 0x0F) << 8) |
465 pressure
= packet
[4];
467 if (ts
->event_format
== 0) {
468 touch_major
= packet
[5];
469 touch_minor
= packet
[5];
471 touch_major
= packet
[6];
472 touch_minor
= packet
[7];
478 /* Touch + Force(Pressure) */
479 id
= (packet
[0] & 0x0F) - 1;
480 hover
= packet
[1] & BIT(2);
481 palm
= packet
[1] & BIT(1);
482 state
= packet
[1] & BIT(0);
483 x
= ((packet
[2] & 0x0F) << 8) | packet
[3];
484 y
= (((packet
[2] >> 4) & 0x0F) << 8) |
487 pressure_stage
= (packet
[7] & 0xF0) >> 4;
488 pressure
= ((packet
[7] & 0x0F) << 8) |
490 touch_major
= packet
[9];
491 touch_minor
= packet
[10];
495 dev_dbg(&ts
->client
->dev
,
496 "Screen - Slot: %d State: %d X: %04d Y: %04d Z: %d\n",
497 id
, state
, x
, y
, pressure
);
499 if (unlikely(id
< 0 || id
>= MIP4_MAX_FINGERS
)) {
500 dev_err(&ts
->client
->dev
, "Screen - invalid slot ID: %d\n", id
);
502 /* Press or Move event */
503 input_mt_slot(ts
->input
, id
);
504 input_mt_report_slot_state(ts
->input
, MT_TOOL_FINGER
, true);
505 input_report_abs(ts
->input
, ABS_MT_POSITION_X
, x
);
506 input_report_abs(ts
->input
, ABS_MT_POSITION_Y
, y
);
507 input_report_abs(ts
->input
, ABS_MT_PRESSURE
, pressure
);
508 input_report_abs(ts
->input
, ABS_MT_TOUCH_MAJOR
, touch_major
);
509 input_report_abs(ts
->input
, ABS_MT_TOUCH_MINOR
, touch_minor
);
512 input_mt_slot(ts
->input
, id
);
513 input_mt_report_slot_state(ts
->input
, MT_TOOL_FINGER
, 0);
516 input_mt_sync_frame(ts
->input
);
519 static int mip4_handle_packet(struct mip4_ts
*ts
, u8
*packet
)
523 switch (ts
->event_format
) {
526 type
= (packet
[0] & 0x40) >> 6;
530 type
= (packet
[0] & 0xF0) >> 4;
534 /* Should not happen unless we have corrupted firmware */
538 dev_dbg(&ts
->client
->dev
, "Type: %d\n", type
);
540 /* Report input event */
542 case MIP4_EVENT_INPUT_TYPE_KEY
:
543 mip4_report_keys(ts
, packet
);
546 case MIP4_EVENT_INPUT_TYPE_SCREEN
:
547 mip4_report_touch(ts
, packet
);
551 dev_err(&ts
->client
->dev
, "Unknown event type: %d\n", type
);
558 static irqreturn_t
mip4_interrupt(int irq
, void *dev_id
)
560 struct mip4_ts
*ts
= dev_id
;
561 struct i2c_client
*client
= ts
->client
;
568 /* Read packet info */
569 cmd
[0] = MIP4_R0_EVENT
;
570 cmd
[1] = MIP4_R1_EVENT_PACKET_INFO
;
571 error
= mip4_i2c_xfer(ts
, cmd
, sizeof(cmd
), ts
->buf
, 1);
573 dev_err(&client
->dev
,
574 "Failed to read packet info: %d\n", error
);
578 size
= ts
->buf
[0] & 0x7F;
579 alert
= ts
->buf
[0] & BIT(7);
580 dev_dbg(&client
->dev
, "packet size: %d, alert: %d\n", size
, alert
);
584 dev_err(&client
->dev
, "Empty packet\n");
588 /* Read packet data */
589 cmd
[0] = MIP4_R0_EVENT
;
590 cmd
[1] = MIP4_R1_EVENT_PACKET_DATA
;
591 error
= mip4_i2c_xfer(ts
, cmd
, sizeof(cmd
), ts
->buf
, size
);
593 dev_err(&client
->dev
,
594 "Failed to read packet data: %d\n", error
);
599 dev_dbg(&client
->dev
, "Alert: %d\n", ts
->buf
[0]);
601 for (i
= 0; i
< size
; i
+= ts
->event_size
) {
602 error
= mip4_handle_packet(ts
, &ts
->buf
[i
]);
607 input_sync(ts
->input
);
614 static int mip4_input_open(struct input_dev
*dev
)
616 struct mip4_ts
*ts
= input_get_drvdata(dev
);
618 return mip4_enable(ts
);
621 static void mip4_input_close(struct input_dev
*dev
)
623 struct mip4_ts
*ts
= input_get_drvdata(dev
);
628 /*****************************************************************
630 *****************************************************************/
633 #define MIP4_BL_PAGE_SIZE 512 /* 512 */
634 #define MIP4_BL_PACKET_SIZE 512 /* 512, 256, 128, 64, ... */
637 * Firmware binary tail info
640 struct mip4_bin_tail
{
644 __le32 bin_start_addr
;
676 #define MIP4_BIN_TAIL_MARK "MBT\001"
677 #define MIP4_BIN_TAIL_SIZE (sizeof(struct mip4_bin_tail))
680 * Bootloader - Read status
682 static int mip4_bl_read_status(struct mip4_ts
*ts
)
684 u8 cmd
[] = { MIP4_R0_BOOT
, MIP4_R1_BOOT_STATUS
};
686 struct i2c_msg msg
[] = {
688 .addr
= ts
->client
->addr
,
693 .addr
= ts
->client
->addr
,
696 .len
= sizeof(result
),
704 ret
= i2c_transfer(ts
->client
->adapter
, msg
, ARRAY_SIZE(msg
));
705 if (ret
!= ARRAY_SIZE(msg
)) {
706 error
= ret
< 0 ? ret
: -EIO
;
707 dev_err(&ts
->client
->dev
,
708 "Failed to read bootloader status: %d\n",
714 case MIP4_BOOT_STATUS_DONE
:
715 dev_dbg(&ts
->client
->dev
, "%s - done\n", __func__
);
718 case MIP4_BOOT_STATUS_ERROR
:
719 dev_err(&ts
->client
->dev
, "Bootloader failure\n");
722 case MIP4_BOOT_STATUS_BUSY
:
723 dev_dbg(&ts
->client
->dev
, "%s - Busy\n", __func__
);
728 dev_err(&ts
->client
->dev
,
729 "Unexpected bootloader status: %#02x\n",
735 usleep_range(1000, 2000);
742 * Bootloader - Change mode
744 static int mip4_bl_change_mode(struct mip4_ts
*ts
, u8 mode
)
746 u8 mode_chg_cmd
[] = { MIP4_R0_BOOT
, MIP4_R1_BOOT_MODE
, mode
};
747 u8 mode_read_cmd
[] = { MIP4_R0_BOOT
, MIP4_R1_BOOT_MODE
};
749 struct i2c_msg msg
[] = {
751 .addr
= ts
->client
->addr
,
753 .buf
= mode_read_cmd
,
754 .len
= sizeof(mode_read_cmd
),
756 .addr
= ts
->client
->addr
,
759 .len
= sizeof(result
),
767 /* Send mode change command */
768 ret
= i2c_master_send(ts
->client
,
769 mode_chg_cmd
, sizeof(mode_chg_cmd
));
770 if (ret
!= sizeof(mode_chg_cmd
)) {
771 error
= ret
< 0 ? ret
: -EIO
;
772 dev_err(&ts
->client
->dev
,
773 "Failed to send %d mode change: %d (%d)\n",
778 dev_dbg(&ts
->client
->dev
,
779 "Sent mode change request (mode: %d)\n", mode
);
784 /* Verify target mode */
785 ret
= i2c_transfer(ts
->client
->adapter
, msg
, ARRAY_SIZE(msg
));
786 if (ret
!= ARRAY_SIZE(msg
)) {
787 error
= ret
< 0 ? ret
: -EIO
;
788 dev_err(&ts
->client
->dev
,
789 "Failed to read device mode: %d\n", error
);
793 dev_dbg(&ts
->client
->dev
,
794 "Current device mode: %d, want: %d\n", result
, mode
);
805 * Bootloader - Start bootloader mode
807 static int mip4_bl_enter(struct mip4_ts
*ts
)
809 return mip4_bl_change_mode(ts
, MIP4_BOOT_MODE_BOOT
);
813 * Bootloader - Exit bootloader mode
815 static int mip4_bl_exit(struct mip4_ts
*ts
)
817 return mip4_bl_change_mode(ts
, MIP4_BOOT_MODE_APP
);
820 static int mip4_bl_get_address(struct mip4_ts
*ts
, u16
*buf_addr
)
822 u8 cmd
[] = { MIP4_R0_BOOT
, MIP4_R1_BOOT_BUF_ADDR
};
823 u8 result
[sizeof(u16
)];
824 struct i2c_msg msg
[] = {
826 .addr
= ts
->client
->addr
,
831 .addr
= ts
->client
->addr
,
834 .len
= sizeof(result
),
840 ret
= i2c_transfer(ts
->client
->adapter
, msg
, ARRAY_SIZE(msg
));
841 if (ret
!= ARRAY_SIZE(msg
)) {
842 error
= ret
< 0 ? ret
: -EIO
;
843 dev_err(&ts
->client
->dev
,
844 "Failed to retrieve bootloader buffer address: %d\n",
849 *buf_addr
= get_unaligned_le16(result
);
850 dev_dbg(&ts
->client
->dev
,
851 "Bootloader buffer address %#04x\n", *buf_addr
);
856 static int mip4_bl_program_page(struct mip4_ts
*ts
, int offset
,
857 const u8
*data
, int length
, u16 buf_addr
)
865 dev_dbg(&ts
->client
->dev
, "Writing page @%#06x (%d)\n",
868 if (length
> MIP4_BL_PAGE_SIZE
|| length
% MIP4_BL_PACKET_SIZE
) {
869 dev_err(&ts
->client
->dev
,
870 "Invalid page length: %d\n", length
);
874 data_buf
= kmalloc(2 + MIP4_BL_PACKET_SIZE
, GFP_KERNEL
);
879 cmd
[0] = MIP4_R0_BOOT
;
880 cmd
[1] = MIP4_R1_BOOT_TARGET_ADDR
;
881 put_unaligned_le32(offset
, &cmd
[2]);
882 ret
= i2c_master_send(ts
->client
, cmd
, 6);
884 error
= ret
< 0 ? ret
: -EIO
;
885 dev_err(&ts
->client
->dev
,
886 "Failed to send write page address: %d\n", error
);
891 cmd
[0] = MIP4_R0_BOOT
;
892 cmd
[1] = MIP4_R1_BOOT_SIZE
;
893 put_unaligned_le32(length
, &cmd
[2]);
894 ret
= i2c_master_send(ts
->client
, cmd
, 6);
896 error
= ret
< 0 ? ret
: -EIO
;
897 dev_err(&ts
->client
->dev
,
898 "Failed to send write page size: %d\n", error
);
905 buf_offset
+= MIP4_BL_PACKET_SIZE
) {
906 dev_dbg(&ts
->client
->dev
,
907 "writing chunk at %#04x (size %d)\n",
908 buf_offset
, MIP4_BL_PACKET_SIZE
);
909 put_unaligned_be16(buf_addr
+ buf_offset
, data_buf
);
910 memcpy(&data_buf
[2], &data
[buf_offset
], MIP4_BL_PACKET_SIZE
);
911 ret
= i2c_master_send(ts
->client
,
912 data_buf
, 2 + MIP4_BL_PACKET_SIZE
);
913 if (ret
!= 2 + MIP4_BL_PACKET_SIZE
) {
914 error
= ret
< 0 ? ret
: -EIO
;
915 dev_err(&ts
->client
->dev
,
916 "Failed to read chunk at %#04x (size %d): %d\n",
917 buf_offset
, MIP4_BL_PACKET_SIZE
, error
);
923 cmd
[0] = MIP4_R0_BOOT
;
924 cmd
[1] = MIP4_R1_BOOT_CMD
;
925 cmd
[2] = MIP4_BOOT_CMD_PROGRAM
;
926 ret
= i2c_master_send(ts
->client
, cmd
, 3);
928 error
= ret
< 0 ? ret
: -EIO
;
929 dev_err(&ts
->client
->dev
,
930 "Failed to send 'write' command: %d\n", error
);
935 error
= mip4_bl_read_status(ts
);
939 return error
? error
: 0;
942 static int mip4_bl_verify_page(struct mip4_ts
*ts
, int offset
,
943 const u8
*data
, int length
, int buf_addr
)
948 struct i2c_msg msg
[] = {
950 .addr
= ts
->client
->addr
,
955 .addr
= ts
->client
->addr
,
957 .len
= MIP4_BL_PACKET_SIZE
,
963 dev_dbg(&ts
->client
->dev
, "Validating page @%#06x (%d)\n",
967 cmd
[0] = MIP4_R0_BOOT
;
968 cmd
[1] = MIP4_R1_BOOT_TARGET_ADDR
;
969 put_unaligned_le32(offset
, &cmd
[2]);
970 ret
= i2c_master_send(ts
->client
, cmd
, 6);
972 error
= ret
< 0 ? ret
: -EIO
;
973 dev_err(&ts
->client
->dev
,
974 "Failed to send read page address: %d\n", error
);
979 cmd
[0] = MIP4_R0_BOOT
;
980 cmd
[1] = MIP4_R1_BOOT_SIZE
;
981 put_unaligned_le32(length
, &cmd
[2]);
982 ret
= i2c_master_send(ts
->client
, cmd
, 6);
984 error
= ret
< 0 ? ret
: -EIO
;
985 dev_err(&ts
->client
->dev
,
986 "Failed to send read page size: %d\n", error
);
991 cmd
[0] = MIP4_R0_BOOT
;
992 cmd
[1] = MIP4_R1_BOOT_CMD
;
993 cmd
[2] = MIP4_BOOT_CMD_READ
;
994 ret
= i2c_master_send(ts
->client
, cmd
, 3);
996 error
= ret
< 0 ? ret
: -EIO
;
997 dev_err(&ts
->client
->dev
,
998 "Failed to send 'read' command: %d\n", error
);
1003 error
= mip4_bl_read_status(ts
);
1008 msg
[1].buf
= read_buf
= kmalloc(MIP4_BL_PACKET_SIZE
, GFP_KERNEL
);
1012 for (buf_offset
= 0;
1013 buf_offset
< length
;
1014 buf_offset
+= MIP4_BL_PACKET_SIZE
) {
1015 dev_dbg(&ts
->client
->dev
,
1016 "reading chunk at %#04x (size %d)\n",
1017 buf_offset
, MIP4_BL_PACKET_SIZE
);
1018 put_unaligned_be16(buf_addr
+ buf_offset
, cmd
);
1019 ret
= i2c_transfer(ts
->client
->adapter
, msg
, ARRAY_SIZE(msg
));
1020 if (ret
!= ARRAY_SIZE(msg
)) {
1021 error
= ret
< 0 ? ret
: -EIO
;
1022 dev_err(&ts
->client
->dev
,
1023 "Failed to read chunk at %#04x (size %d): %d\n",
1024 buf_offset
, MIP4_BL_PACKET_SIZE
, error
);
1028 if (memcmp(&data
[buf_offset
], read_buf
, MIP4_BL_PACKET_SIZE
)) {
1029 dev_err(&ts
->client
->dev
,
1030 "Failed to validate chunk at %#04x (size %d)\n",
1031 buf_offset
, MIP4_BL_PACKET_SIZE
);
1032 #if MIP4_FW_UPDATE_DEBUG
1033 print_hex_dump(KERN_DEBUG
,
1034 MIP4_DEVICE_NAME
" F/W File: ",
1035 DUMP_PREFIX_OFFSET
, 16, 1,
1036 data
+ offset
, MIP4_BL_PACKET_SIZE
,
1038 print_hex_dump(KERN_DEBUG
,
1039 MIP4_DEVICE_NAME
" F/W Chip: ",
1040 DUMP_PREFIX_OFFSET
, 16, 1,
1041 read_buf
, MIP4_BL_PAGE_SIZE
, false);
1049 return error
? error
: 0;
1053 * Flash chip firmware
1055 static int mip4_flash_fw(struct mip4_ts
*ts
,
1056 const u8
*fw_data
, u32 fw_size
, u32 fw_offset
)
1058 struct i2c_client
*client
= ts
->client
;
1063 /* Enter bootloader mode */
1064 dev_dbg(&client
->dev
, "Entering bootloader mode\n");
1066 error
= mip4_bl_enter(ts
);
1068 dev_err(&client
->dev
,
1069 "Failed to enter bootloader mode: %d\n",
1075 error
= mip4_bl_get_address(ts
, &buf_addr
);
1079 /* Program & Verify */
1080 dev_dbg(&client
->dev
,
1081 "Program & Verify, page size: %d, packet size: %d\n",
1082 MIP4_BL_PAGE_SIZE
, MIP4_BL_PACKET_SIZE
);
1084 for (offset
= fw_offset
;
1085 offset
< fw_offset
+ fw_size
;
1086 offset
+= MIP4_BL_PAGE_SIZE
) {
1088 error
= mip4_bl_program_page(ts
, offset
, fw_data
+ offset
,
1089 MIP4_BL_PAGE_SIZE
, buf_addr
);
1094 error
= mip4_bl_verify_page(ts
, offset
, fw_data
+ offset
,
1095 MIP4_BL_PAGE_SIZE
, buf_addr
);
1101 /* Exit bootloader mode */
1102 dev_dbg(&client
->dev
, "Exiting bootloader mode\n");
1104 error2
= mip4_bl_exit(ts
);
1106 dev_err(&client
->dev
,
1107 "Failed to exit bootloader mode: %d\n", error2
);
1116 mip4_query_device(ts
);
1118 /* Refresh device parameters */
1119 input_set_abs_params(ts
->input
, ABS_MT_POSITION_X
, 0, ts
->max_x
, 0, 0);
1120 input_set_abs_params(ts
->input
, ABS_MT_POSITION_Y
, 0, ts
->max_y
, 0, 0);
1121 input_set_abs_params(ts
->input
, ABS_X
, 0, ts
->max_x
, 0, 0);
1122 input_set_abs_params(ts
->input
, ABS_Y
, 0, ts
->max_y
, 0, 0);
1123 input_abs_set_res(ts
->input
, ABS_MT_POSITION_X
, ts
->ppm_x
);
1124 input_abs_set_res(ts
->input
, ABS_MT_POSITION_Y
, ts
->ppm_y
);
1125 input_abs_set_res(ts
->input
, ABS_X
, ts
->ppm_x
);
1126 input_abs_set_res(ts
->input
, ABS_Y
, ts
->ppm_y
);
1128 return error
? error
: 0;
1131 static int mip4_parse_firmware(struct mip4_ts
*ts
, const struct firmware
*fw
,
1132 u32
*fw_offset_start
, u32
*fw_size
,
1133 const struct mip4_bin_tail
**pfw_info
)
1135 const struct mip4_bin_tail
*fw_info
;
1136 struct mip4_fw_version fw_version
;
1139 if (fw
->size
< MIP4_BIN_TAIL_SIZE
) {
1140 dev_err(&ts
->client
->dev
,
1141 "Invalid firmware, size mismatch (tail %zd vs %zd)\n",
1142 MIP4_BIN_TAIL_SIZE
, fw
->size
);
1146 fw_info
= (const void *)&fw
->data
[fw
->size
- MIP4_BIN_TAIL_SIZE
];
1148 #if MIP4_FW_UPDATE_DEBUG
1149 print_hex_dump(KERN_ERR
, MIP4_DEVICE_NAME
" Bin Info: ",
1150 DUMP_PREFIX_OFFSET
, 16, 1, *fw_info
, tail_size
, false);
1153 tail_size
= get_unaligned_le16(&fw_info
->tail_size
);
1154 if (tail_size
!= MIP4_BIN_TAIL_SIZE
) {
1155 dev_err(&ts
->client
->dev
,
1156 "wrong tail size: %d (expected %zd)\n",
1157 tail_size
, MIP4_BIN_TAIL_SIZE
);
1161 /* Check bin format */
1162 if (memcmp(fw_info
->tail_mark
, MIP4_BIN_TAIL_MARK
,
1163 sizeof(fw_info
->tail_mark
))) {
1164 dev_err(&ts
->client
->dev
,
1165 "unable to locate tail marker (%*ph vs %*ph)\n",
1166 (int)sizeof(fw_info
->tail_mark
), fw_info
->tail_mark
,
1167 (int)sizeof(fw_info
->tail_mark
), MIP4_BIN_TAIL_MARK
);
1171 *fw_offset_start
= get_unaligned_le32(&fw_info
->bin_start_addr
);
1172 *fw_size
= get_unaligned_le32(&fw_info
->bin_length
);
1174 dev_dbg(&ts
->client
->dev
,
1175 "F/W Data offset: %#08x, size: %d\n",
1176 *fw_offset_start
, *fw_size
);
1178 if (*fw_size
% MIP4_BL_PAGE_SIZE
) {
1179 dev_err(&ts
->client
->dev
,
1180 "encoded fw length %d is not multiple of pages (%d)\n",
1181 *fw_size
, MIP4_BL_PAGE_SIZE
);
1185 if (fw
->size
!= *fw_offset_start
+ *fw_size
) {
1186 dev_err(&ts
->client
->dev
,
1187 "Wrong firmware size, expected %d bytes, got %zd\n",
1188 *fw_offset_start
+ *fw_size
, fw
->size
);
1192 mip4_parse_fw_version((const u8
*)&fw_info
->ver_boot
, &fw_version
);
1194 dev_dbg(&ts
->client
->dev
,
1195 "F/W file version %04X %04X %04X %04X\n",
1196 fw_version
.boot
, fw_version
.core
,
1197 fw_version
.app
, fw_version
.param
);
1199 dev_dbg(&ts
->client
->dev
, "F/W chip version: %04X %04X %04X %04X\n",
1200 ts
->fw_version
.boot
, ts
->fw_version
.core
,
1201 ts
->fw_version
.app
, ts
->fw_version
.param
);
1203 /* Check F/W type */
1204 if (fw_version
.boot
!= 0xEEEE && fw_version
.boot
!= 0xFFFF &&
1205 fw_version
.core
== 0xEEEE &&
1206 fw_version
.app
== 0xEEEE &&
1207 fw_version
.param
== 0xEEEE) {
1208 dev_dbg(&ts
->client
->dev
, "F/W type: Bootloader\n");
1209 } else if (fw_version
.boot
== 0xEEEE &&
1210 fw_version
.core
!= 0xEEEE && fw_version
.core
!= 0xFFFF &&
1211 fw_version
.app
!= 0xEEEE && fw_version
.app
!= 0xFFFF &&
1212 fw_version
.param
!= 0xEEEE && fw_version
.param
!= 0xFFFF) {
1213 dev_dbg(&ts
->client
->dev
, "F/W type: Main\n");
1215 dev_err(&ts
->client
->dev
, "Wrong firmware type\n");
1222 static int mip4_execute_fw_update(struct mip4_ts
*ts
, const struct firmware
*fw
)
1224 const struct mip4_bin_tail
*fw_info
;
1225 u32 fw_start_offset
;
1230 error
= mip4_parse_firmware(ts
, fw
,
1231 &fw_start_offset
, &fw_size
, &fw_info
);
1235 if (ts
->input
->users
) {
1236 disable_irq(ts
->client
->irq
);
1238 error
= mip4_power_on(ts
);
1243 /* Update firmware */
1245 error
= mip4_flash_fw(ts
, fw
->data
, fw_size
, fw_start_offset
);
1248 } while (--retires
);
1251 dev_err(&ts
->client
->dev
,
1252 "Failed to flash firmware: %d\n", error
);
1255 if (ts
->input
->users
)
1256 enable_irq(ts
->client
->irq
);
1260 return error
? error
: 0;
1263 static ssize_t
mip4_sysfs_fw_update(struct device
*dev
,
1264 struct device_attribute
*attr
,
1265 const char *buf
, size_t count
)
1267 struct i2c_client
*client
= to_i2c_client(dev
);
1268 struct mip4_ts
*ts
= i2c_get_clientdata(client
);
1269 const struct firmware
*fw
;
1272 error
= request_firmware(&fw
, MIP4_FW_NAME
, dev
);
1274 dev_err(&ts
->client
->dev
,
1275 "Failed to retrieve firmware %s: %d\n",
1276 MIP4_FW_NAME
, error
);
1281 * Take input mutex to prevent racing with itself and also with
1282 * userspace opening and closing the device and also suspend/resume
1285 mutex_lock(&ts
->input
->mutex
);
1287 error
= mip4_execute_fw_update(ts
, fw
);
1289 mutex_unlock(&ts
->input
->mutex
);
1291 release_firmware(fw
);
1294 dev_err(&ts
->client
->dev
,
1295 "Firmware update failed: %d\n", error
);
1302 static DEVICE_ATTR(update_fw
, S_IWUSR
, NULL
, mip4_sysfs_fw_update
);
1304 static ssize_t
mip4_sysfs_read_fw_version(struct device
*dev
,
1305 struct device_attribute
*attr
,
1308 struct i2c_client
*client
= to_i2c_client(dev
);
1309 struct mip4_ts
*ts
= i2c_get_clientdata(client
);
1312 /* Take lock to prevent racing with firmware update */
1313 mutex_lock(&ts
->input
->mutex
);
1315 count
= snprintf(buf
, PAGE_SIZE
, "%04X %04X %04X %04X\n",
1316 ts
->fw_version
.boot
, ts
->fw_version
.core
,
1317 ts
->fw_version
.app
, ts
->fw_version
.param
);
1319 mutex_unlock(&ts
->input
->mutex
);
1324 static DEVICE_ATTR(fw_version
, S_IRUGO
, mip4_sysfs_read_fw_version
, NULL
);
1326 static ssize_t
mip4_sysfs_read_hw_version(struct device
*dev
,
1327 struct device_attribute
*attr
,
1330 struct i2c_client
*client
= to_i2c_client(dev
);
1331 struct mip4_ts
*ts
= i2c_get_clientdata(client
);
1334 /* Take lock to prevent racing with firmware update */
1335 mutex_lock(&ts
->input
->mutex
);
1338 * product_name shows the name or version of the hardware
1339 * paired with current firmware in the chip.
1341 count
= snprintf(buf
, PAGE_SIZE
, "%.*s\n",
1342 (int)sizeof(ts
->product_name
), ts
->product_name
);
1344 mutex_unlock(&ts
->input
->mutex
);
1349 static DEVICE_ATTR(hw_version
, S_IRUGO
, mip4_sysfs_read_hw_version
, NULL
);
1351 static ssize_t
mip4_sysfs_read_ic_name(struct device
*dev
,
1352 struct device_attribute
*attr
,
1355 struct i2c_client
*client
= to_i2c_client(dev
);
1356 struct mip4_ts
*ts
= i2c_get_clientdata(client
);
1359 mutex_lock(&ts
->input
->mutex
);
1361 count
= snprintf(buf
, PAGE_SIZE
, "%.*s\n",
1362 (int)sizeof(ts
->ic_name
), ts
->ic_name
);
1364 mutex_unlock(&ts
->input
->mutex
);
1369 static DEVICE_ATTR(ic_name
, S_IRUGO
, mip4_sysfs_read_ic_name
, NULL
);
1371 static struct attribute
*mip4_attrs
[] = {
1372 &dev_attr_fw_version
.attr
,
1373 &dev_attr_hw_version
.attr
,
1374 &dev_attr_ic_name
.attr
,
1375 &dev_attr_update_fw
.attr
,
1379 static const struct attribute_group mip4_attr_group
= {
1380 .attrs
= mip4_attrs
,
1383 static void mip4_sysfs_remove(void *_data
)
1385 struct mip4_ts
*ts
= _data
;
1387 sysfs_remove_group(&ts
->client
->dev
.kobj
, &mip4_attr_group
);
1390 static int mip4_probe(struct i2c_client
*client
, const struct i2c_device_id
*id
)
1393 struct input_dev
*input
;
1396 if (!i2c_check_functionality(client
->adapter
, I2C_FUNC_I2C
)) {
1397 dev_err(&client
->dev
, "Not supported I2C adapter\n");
1401 ts
= devm_kzalloc(&client
->dev
, sizeof(*ts
), GFP_KERNEL
);
1405 input
= devm_input_allocate_device(&client
->dev
);
1409 ts
->client
= client
;
1412 snprintf(ts
->phys
, sizeof(ts
->phys
),
1413 "%s/input0", dev_name(&client
->dev
));
1415 ts
->gpio_ce
= devm_gpiod_get_optional(&client
->dev
,
1416 "ce", GPIOD_OUT_LOW
);
1417 if (IS_ERR(ts
->gpio_ce
)) {
1418 error
= PTR_ERR(ts
->gpio_ce
);
1419 if (error
!= EPROBE_DEFER
)
1420 dev_err(&client
->dev
,
1421 "Failed to get gpio: %d\n", error
);
1425 error
= mip4_power_on(ts
);
1428 error
= mip4_query_device(ts
);
1433 input
->name
= "MELFAS MIP4 Touchscreen";
1434 input
->phys
= ts
->phys
;
1436 input
->id
.bustype
= BUS_I2C
;
1437 input
->id
.vendor
= 0x13c5;
1439 input
->open
= mip4_input_open
;
1440 input
->close
= mip4_input_close
;
1442 input_set_drvdata(input
, ts
);
1444 input
->keycode
= ts
->key_code
;
1445 input
->keycodesize
= sizeof(*ts
->key_code
);
1446 input
->keycodemax
= ts
->key_num
;
1448 input_set_abs_params(input
, ABS_MT_POSITION_X
, 0, ts
->max_x
, 0, 0);
1449 input_set_abs_params(input
, ABS_MT_POSITION_Y
, 0, ts
->max_y
, 0, 0);
1450 input_set_abs_params(input
, ABS_MT_PRESSURE
,
1451 MIP4_PRESSURE_MIN
, MIP4_PRESSURE_MAX
, 0, 0);
1452 input_set_abs_params(input
, ABS_MT_TOUCH_MAJOR
,
1453 MIP4_TOUCH_MAJOR_MIN
, MIP4_TOUCH_MAJOR_MAX
, 0, 0);
1454 input_set_abs_params(input
, ABS_MT_TOUCH_MINOR
,
1455 MIP4_TOUCH_MINOR_MIN
, MIP4_TOUCH_MINOR_MAX
, 0, 0);
1456 input_abs_set_res(ts
->input
, ABS_MT_POSITION_X
, ts
->ppm_x
);
1457 input_abs_set_res(ts
->input
, ABS_MT_POSITION_Y
, ts
->ppm_y
);
1459 error
= input_mt_init_slots(input
, MIP4_MAX_FINGERS
, INPUT_MT_DIRECT
);
1463 i2c_set_clientdata(client
, ts
);
1465 error
= devm_request_threaded_irq(&client
->dev
, client
->irq
,
1466 NULL
, mip4_interrupt
,
1467 IRQF_ONESHOT
, MIP4_DEVICE_NAME
, ts
);
1469 dev_err(&client
->dev
,
1470 "Failed to request interrupt %d: %d\n",
1471 client
->irq
, error
);
1475 disable_irq(client
->irq
);
1477 error
= input_register_device(input
);
1479 dev_err(&client
->dev
,
1480 "Failed to register input device: %d\n", error
);
1484 error
= sysfs_create_group(&client
->dev
.kobj
, &mip4_attr_group
);
1486 dev_err(&client
->dev
,
1487 "Failed to create sysfs attribute group: %d\n", error
);
1491 error
= devm_add_action(&client
->dev
, mip4_sysfs_remove
, ts
);
1493 mip4_sysfs_remove(ts
);
1494 dev_err(&client
->dev
,
1495 "Failed to install sysfs remoce action: %d\n", error
);
1502 static int __maybe_unused
mip4_suspend(struct device
*dev
)
1504 struct i2c_client
*client
= to_i2c_client(dev
);
1505 struct mip4_ts
*ts
= i2c_get_clientdata(client
);
1506 struct input_dev
*input
= ts
->input
;
1508 mutex_lock(&input
->mutex
);
1510 if (device_may_wakeup(dev
))
1511 ts
->wake_irq_enabled
= enable_irq_wake(client
->irq
) == 0;
1512 else if (input
->users
)
1515 mutex_unlock(&input
->mutex
);
1520 static int __maybe_unused
mip4_resume(struct device
*dev
)
1522 struct i2c_client
*client
= to_i2c_client(dev
);
1523 struct mip4_ts
*ts
= i2c_get_clientdata(client
);
1524 struct input_dev
*input
= ts
->input
;
1526 mutex_lock(&input
->mutex
);
1528 if (ts
->wake_irq_enabled
)
1529 disable_irq_wake(client
->irq
);
1530 else if (input
->users
)
1533 mutex_unlock(&input
->mutex
);
1538 static SIMPLE_DEV_PM_OPS(mip4_pm_ops
, mip4_suspend
, mip4_resume
);
1541 static const struct of_device_id mip4_of_match
[] = {
1542 { .compatible
= "melfas,"MIP4_DEVICE_NAME
, },
1545 MODULE_DEVICE_TABLE(of
, mip4_of_match
);
1549 static const struct acpi_device_id mip4_acpi_match
[] = {
1553 MODULE_DEVICE_TABLE(acpi
, mip4_acpi_match
);
1556 static const struct i2c_device_id mip4_i2c_ids
[] = {
1557 { MIP4_DEVICE_NAME
, 0 },
1560 MODULE_DEVICE_TABLE(i2c
, mip4_i2c_ids
);
1562 static struct i2c_driver mip4_driver
= {
1563 .id_table
= mip4_i2c_ids
,
1564 .probe
= mip4_probe
,
1566 .name
= MIP4_DEVICE_NAME
,
1567 .of_match_table
= of_match_ptr(mip4_of_match
),
1568 .acpi_match_table
= ACPI_PTR(mip4_acpi_match
),
1572 module_i2c_driver(mip4_driver
);
1574 MODULE_DESCRIPTION("MELFAS MIP4 Touchscreen");
1575 MODULE_VERSION("2016.09.28");
1576 MODULE_AUTHOR("Sangwon Jee <jeesw@melfas.com>");
1577 MODULE_LICENSE("GPL");