1 // SPDX-License-Identifier: GPL-2.0-only
3 * MCP2221A - Microchip USB to I2C Host Protocol Bridge
5 * Copyright (c) 2020, Rishi Gupta <gupt21@gmail.com>
7 * Datasheet: https://ww1.microchip.com/downloads/en/DeviceDoc/20005565B.pdf
10 #include <linux/module.h>
11 #include <linux/err.h>
12 #include <linux/mutex.h>
13 #include <linux/completion.h>
14 #include <linux/delay.h>
15 #include <linux/hid.h>
16 #include <linux/hidraw.h>
17 #include <linux/i2c.h>
18 #include <linux/gpio/driver.h>
21 /* Commands codes in a raw output report */
23 MCP2221_I2C_WR_DATA = 0x90,
24 MCP2221_I2C_WR_NO_STOP = 0x94,
25 MCP2221_I2C_RD_DATA = 0x91,
26 MCP2221_I2C_RD_RPT_START = 0x93,
27 MCP2221_I2C_GET_DATA = 0x40,
28 MCP2221_I2C_PARAM_OR_STATUS = 0x10,
29 MCP2221_I2C_SET_SPEED = 0x20,
30 MCP2221_I2C_CANCEL = 0x10,
31 MCP2221_GPIO_SET = 0x50,
32 MCP2221_GPIO_GET = 0x51,
35 /* Response codes in a raw input report */
37 MCP2221_SUCCESS = 0x00,
38 MCP2221_I2C_ENG_BUSY = 0x01,
39 MCP2221_I2C_START_TOUT = 0x12,
40 MCP2221_I2C_STOP_TOUT = 0x62,
41 MCP2221_I2C_WRADDRL_TOUT = 0x23,
42 MCP2221_I2C_WRDATA_TOUT = 0x44,
43 MCP2221_I2C_WRADDRL_NACK = 0x25,
44 MCP2221_I2C_MASK_ADDR_NACK = 0x40,
45 MCP2221_I2C_WRADDRL_SEND = 0x21,
46 MCP2221_I2C_ADDR_NACK = 0x25,
47 MCP2221_I2C_READ_COMPL = 0x55,
48 MCP2221_ALT_F_NOT_GPIOV = 0xEE,
49 MCP2221_ALT_F_NOT_GPIOD = 0xEF,
52 /* MCP GPIO direction encoding */
54 MCP2221_DIR_OUT = 0x00,
55 MCP2221_DIR_IN = 0x01,
60 /* MCP GPIO set command layout */
72 /* MCP GPIO get command layout */
83 * There is no way to distinguish responses. Therefore next command
84 * is sent only after response to previous has been received. Mutex
85 * lock is used for this purpose mainly.
88 struct hid_device *hdev;
89 struct i2c_adapter adapter;
91 struct completion wait_in_report;
103 * Default i2c bus clock frequency 400 kHz. Modify this if you
104 * want to set some other frequency (min 50 kHz - max 400 kHz).
106 static uint i2c_clk_freq = 400;
108 /* Synchronously send output report to the device */
109 static int mcp_send_report(struct mcp2221 *mcp,
110 u8 *out_report, size_t len)
115 buf = kmemdup(out_report, len, GFP_KERNEL);
119 /* mcp2221 uses interrupt endpoint for out reports */
120 ret = hid_hw_output_report(mcp->hdev, buf, len);
129 * Send o/p report to the device and wait for i/p report to be
130 * received from the device. If the device does not respond,
133 static int mcp_send_data_req_status(struct mcp2221 *mcp,
134 u8 *out_report, int len)
139 reinit_completion(&mcp->wait_in_report);
141 ret = mcp_send_report(mcp, out_report, len);
145 t = wait_for_completion_timeout(&mcp->wait_in_report,
146 msecs_to_jiffies(4000));
153 /* Check pass/fail for actual communication with i2c slave */
154 static int mcp_chk_last_cmd_status(struct mcp2221 *mcp)
156 memset(mcp->txbuf, 0, 8);
157 mcp->txbuf[0] = MCP2221_I2C_PARAM_OR_STATUS;
159 return mcp_send_data_req_status(mcp, mcp->txbuf, 8);
162 /* Cancels last command releasing i2c bus just in case occupied */
163 static int mcp_cancel_last_cmd(struct mcp2221 *mcp)
165 memset(mcp->txbuf, 0, 8);
166 mcp->txbuf[0] = MCP2221_I2C_PARAM_OR_STATUS;
167 mcp->txbuf[2] = MCP2221_I2C_CANCEL;
169 return mcp_send_data_req_status(mcp, mcp->txbuf, 8);
172 static int mcp_set_i2c_speed(struct mcp2221 *mcp)
176 memset(mcp->txbuf, 0, 8);
177 mcp->txbuf[0] = MCP2221_I2C_PARAM_OR_STATUS;
178 mcp->txbuf[3] = MCP2221_I2C_SET_SPEED;
179 mcp->txbuf[4] = mcp->cur_i2c_clk_div;
181 ret = mcp_send_data_req_status(mcp, mcp->txbuf, 8);
183 /* Small delay is needed here */
184 usleep_range(980, 1000);
185 mcp_cancel_last_cmd(mcp);
192 * An output report can contain minimum 1 and maximum 60 user data
193 * bytes. If the number of data bytes is more then 60, we send it
194 * in chunks of 60 bytes. Last chunk may contain exactly 60 or less
195 * bytes. Total number of bytes is informed in very first report to
196 * mcp2221, from that point onwards it first collect all the data
197 * from host and then send to i2c slave device.
199 static int mcp_i2c_write(struct mcp2221 *mcp,
200 struct i2c_msg *msg, int type, u8 last_status)
202 int ret, len, idx, sent;
212 mcp->txbuf[0] = type;
213 mcp->txbuf[1] = msg->len & 0xff;
214 mcp->txbuf[2] = msg->len >> 8;
215 mcp->txbuf[3] = (u8)(msg->addr << 1);
217 memcpy(&mcp->txbuf[4], &msg->buf[idx], len);
219 ret = mcp_send_data_req_status(mcp, mcp->txbuf, len + 4);
223 usleep_range(980, 1000);
226 ret = mcp_chk_last_cmd_status(mcp);
232 if (sent >= msg->len)
236 if ((msg->len - sent) < 60)
237 len = msg->len - sent;
242 * Testing shows delay is needed between successive writes
243 * otherwise next write fails on first-try from i2c core.
244 * This value is obtained through automated stress testing.
246 usleep_range(980, 1000);
253 * Device reads all data (0 - 65535 bytes) from i2c slave device and
254 * stores it in device itself. This data is read back from device to
255 * host in multiples of 60 bytes using input reports.
257 static int mcp_i2c_smbus_read(struct mcp2221 *mcp,
258 struct i2c_msg *msg, int type, u16 smbus_addr,
259 u8 smbus_len, u8 *smbus_buf)
264 mcp->txbuf[0] = type;
266 mcp->txbuf[1] = msg->len & 0xff;
267 mcp->txbuf[2] = msg->len >> 8;
268 mcp->txbuf[3] = (u8)(msg->addr << 1);
269 total_len = msg->len;
270 mcp->rxbuf = msg->buf;
272 mcp->txbuf[1] = smbus_len;
274 mcp->txbuf[3] = (u8)(smbus_addr << 1);
275 total_len = smbus_len;
276 mcp->rxbuf = smbus_buf;
279 ret = mcp_send_data_req_status(mcp, mcp->txbuf, 4);
286 memset(mcp->txbuf, 0, 4);
287 mcp->txbuf[0] = MCP2221_I2C_GET_DATA;
289 ret = mcp_send_data_req_status(mcp, mcp->txbuf, 1);
293 ret = mcp_chk_last_cmd_status(mcp);
297 usleep_range(980, 1000);
298 } while (mcp->rxbuf_idx < total_len);
303 static int mcp_i2c_xfer(struct i2c_adapter *adapter,
304 struct i2c_msg msgs[], int num)
307 struct mcp2221 *mcp = i2c_get_adapdata(adapter);
309 hid_hw_power(mcp->hdev, PM_HINT_FULLON);
311 mutex_lock(&mcp->lock);
313 /* Setting speed before every transaction is required for mcp2221 */
314 ret = mcp_set_i2c_speed(mcp);
319 if (msgs->flags & I2C_M_RD) {
320 ret = mcp_i2c_smbus_read(mcp, msgs, MCP2221_I2C_RD_DATA,
323 ret = mcp_i2c_write(mcp, msgs, MCP2221_I2C_WR_DATA, 1);
328 } else if (num == 2) {
329 /* Ex transaction; send reg address and read its contents */
330 if (msgs[0].addr == msgs[1].addr &&
331 !(msgs[0].flags & I2C_M_RD) &&
332 (msgs[1].flags & I2C_M_RD)) {
334 ret = mcp_i2c_write(mcp, &msgs[0],
335 MCP2221_I2C_WR_NO_STOP, 0);
339 ret = mcp_i2c_smbus_read(mcp, &msgs[1],
340 MCP2221_I2C_RD_RPT_START,
346 dev_err(&adapter->dev,
347 "unsupported multi-msg i2c transaction\n");
351 dev_err(&adapter->dev,
352 "unsupported multi-msg i2c transaction\n");
357 hid_hw_power(mcp->hdev, PM_HINT_NORMAL);
358 mutex_unlock(&mcp->lock);
362 static int mcp_smbus_write(struct mcp2221 *mcp, u16 addr,
363 u8 command, u8 *buf, u8 len, int type,
368 mcp->txbuf[0] = type;
369 mcp->txbuf[1] = len + 1; /* 1 is due to command byte itself */
371 mcp->txbuf[3] = (u8)(addr << 1);
372 mcp->txbuf[4] = command;
379 mcp->txbuf[5] = buf[0];
383 mcp->txbuf[5] = buf[0];
384 mcp->txbuf[6] = buf[1];
388 if (len > I2C_SMBUS_BLOCK_MAX)
391 memcpy(&mcp->txbuf[5], buf, len);
395 ret = mcp_send_data_req_status(mcp, mcp->txbuf, data_len);
400 usleep_range(980, 1000);
402 ret = mcp_chk_last_cmd_status(mcp);
410 static int mcp_smbus_xfer(struct i2c_adapter *adapter, u16 addr,
411 unsigned short flags, char read_write,
412 u8 command, int size,
413 union i2c_smbus_data *data)
416 struct mcp2221 *mcp = i2c_get_adapdata(adapter);
418 hid_hw_power(mcp->hdev, PM_HINT_FULLON);
420 mutex_lock(&mcp->lock);
422 ret = mcp_set_i2c_speed(mcp);
428 case I2C_SMBUS_QUICK:
429 if (read_write == I2C_SMBUS_READ)
430 ret = mcp_i2c_smbus_read(mcp, NULL, MCP2221_I2C_RD_DATA,
431 addr, 0, &data->byte);
433 ret = mcp_smbus_write(mcp, addr, command, NULL,
434 0, MCP2221_I2C_WR_DATA, 1);
437 if (read_write == I2C_SMBUS_READ)
438 ret = mcp_i2c_smbus_read(mcp, NULL, MCP2221_I2C_RD_DATA,
439 addr, 1, &data->byte);
441 ret = mcp_smbus_write(mcp, addr, command, NULL,
442 0, MCP2221_I2C_WR_DATA, 1);
444 case I2C_SMBUS_BYTE_DATA:
445 if (read_write == I2C_SMBUS_READ) {
446 ret = mcp_smbus_write(mcp, addr, command, NULL,
447 0, MCP2221_I2C_WR_NO_STOP, 0);
451 ret = mcp_i2c_smbus_read(mcp, NULL,
452 MCP2221_I2C_RD_RPT_START,
453 addr, 1, &data->byte);
455 ret = mcp_smbus_write(mcp, addr, command, &data->byte,
456 1, MCP2221_I2C_WR_DATA, 1);
459 case I2C_SMBUS_WORD_DATA:
460 if (read_write == I2C_SMBUS_READ) {
461 ret = mcp_smbus_write(mcp, addr, command, NULL,
462 0, MCP2221_I2C_WR_NO_STOP, 0);
466 ret = mcp_i2c_smbus_read(mcp, NULL,
467 MCP2221_I2C_RD_RPT_START,
468 addr, 2, (u8 *)&data->word);
470 ret = mcp_smbus_write(mcp, addr, command,
471 (u8 *)&data->word, 2,
472 MCP2221_I2C_WR_DATA, 1);
475 case I2C_SMBUS_BLOCK_DATA:
476 if (read_write == I2C_SMBUS_READ) {
477 ret = mcp_smbus_write(mcp, addr, command, NULL,
478 0, MCP2221_I2C_WR_NO_STOP, 1);
483 mcp->rxbuf = data->block;
484 mcp->txbuf[0] = MCP2221_I2C_GET_DATA;
485 ret = mcp_send_data_req_status(mcp, mcp->txbuf, 1);
489 if (!data->block[0]) {
493 ret = mcp_smbus_write(mcp, addr, command, data->block,
495 MCP2221_I2C_WR_DATA, 1);
498 case I2C_SMBUS_I2C_BLOCK_DATA:
499 if (read_write == I2C_SMBUS_READ) {
500 ret = mcp_smbus_write(mcp, addr, command, NULL,
501 0, MCP2221_I2C_WR_NO_STOP, 1);
506 mcp->rxbuf = data->block;
507 mcp->txbuf[0] = MCP2221_I2C_GET_DATA;
508 ret = mcp_send_data_req_status(mcp, mcp->txbuf, 1);
512 if (!data->block[0]) {
516 ret = mcp_smbus_write(mcp, addr, command,
517 &data->block[1], data->block[0],
518 MCP2221_I2C_WR_DATA, 1);
521 case I2C_SMBUS_PROC_CALL:
522 ret = mcp_smbus_write(mcp, addr, command,
524 2, MCP2221_I2C_WR_NO_STOP, 0);
528 ret = mcp_i2c_smbus_read(mcp, NULL,
529 MCP2221_I2C_RD_RPT_START,
530 addr, 2, (u8 *)&data->word);
532 case I2C_SMBUS_BLOCK_PROC_CALL:
533 ret = mcp_smbus_write(mcp, addr, command, data->block,
535 MCP2221_I2C_WR_NO_STOP, 0);
539 ret = mcp_i2c_smbus_read(mcp, NULL,
540 MCP2221_I2C_RD_RPT_START,
541 addr, I2C_SMBUS_BLOCK_MAX,
545 dev_err(&mcp->adapter.dev,
546 "unsupported smbus transaction size:%d\n", size);
551 hid_hw_power(mcp->hdev, PM_HINT_NORMAL);
552 mutex_unlock(&mcp->lock);
556 static u32 mcp_i2c_func(struct i2c_adapter *adapter)
558 return I2C_FUNC_I2C |
559 I2C_FUNC_SMBUS_READ_BLOCK_DATA |
560 I2C_FUNC_SMBUS_BLOCK_PROC_CALL |
561 (I2C_FUNC_SMBUS_EMUL & ~I2C_FUNC_SMBUS_PEC);
564 static const struct i2c_algorithm mcp_i2c_algo = {
565 .master_xfer = mcp_i2c_xfer,
566 .smbus_xfer = mcp_smbus_xfer,
567 .functionality = mcp_i2c_func,
570 static int mcp_gpio_get(struct gpio_chip *gc,
574 struct mcp2221 *mcp = gpiochip_get_data(gc);
576 mcp->txbuf[0] = MCP2221_GPIO_GET;
578 mcp->gp_idx = offsetof(struct mcp_get_gpio, gpio[offset].value);
580 mutex_lock(&mcp->lock);
581 ret = mcp_send_data_req_status(mcp, mcp->txbuf, 1);
582 mutex_unlock(&mcp->lock);
587 static void mcp_gpio_set(struct gpio_chip *gc,
588 unsigned int offset, int value)
590 struct mcp2221 *mcp = gpiochip_get_data(gc);
592 memset(mcp->txbuf, 0, 18);
593 mcp->txbuf[0] = MCP2221_GPIO_SET;
595 mcp->gp_idx = offsetof(struct mcp_set_gpio, gpio[offset].value);
597 mcp->txbuf[mcp->gp_idx - 1] = 1;
598 mcp->txbuf[mcp->gp_idx] = !!value;
600 mutex_lock(&mcp->lock);
601 mcp_send_data_req_status(mcp, mcp->txbuf, 18);
602 mutex_unlock(&mcp->lock);
605 static int mcp_gpio_dir_set(struct mcp2221 *mcp,
606 unsigned int offset, u8 val)
608 memset(mcp->txbuf, 0, 18);
609 mcp->txbuf[0] = MCP2221_GPIO_SET;
611 mcp->gp_idx = offsetof(struct mcp_set_gpio, gpio[offset].direction);
613 mcp->txbuf[mcp->gp_idx - 1] = 1;
614 mcp->txbuf[mcp->gp_idx] = val;
616 return mcp_send_data_req_status(mcp, mcp->txbuf, 18);
619 static int mcp_gpio_direction_input(struct gpio_chip *gc,
623 struct mcp2221 *mcp = gpiochip_get_data(gc);
625 mutex_lock(&mcp->lock);
626 ret = mcp_gpio_dir_set(mcp, offset, MCP2221_DIR_IN);
627 mutex_unlock(&mcp->lock);
632 static int mcp_gpio_direction_output(struct gpio_chip *gc,
633 unsigned int offset, int value)
636 struct mcp2221 *mcp = gpiochip_get_data(gc);
638 mutex_lock(&mcp->lock);
639 ret = mcp_gpio_dir_set(mcp, offset, MCP2221_DIR_OUT);
640 mutex_unlock(&mcp->lock);
642 /* Can't configure as output, bailout early */
646 mcp_gpio_set(gc, offset, value);
651 static int mcp_gpio_get_direction(struct gpio_chip *gc,
655 struct mcp2221 *mcp = gpiochip_get_data(gc);
657 mcp->txbuf[0] = MCP2221_GPIO_GET;
659 mcp->gp_idx = offsetof(struct mcp_get_gpio, gpio[offset].direction);
661 mutex_lock(&mcp->lock);
662 ret = mcp_send_data_req_status(mcp, mcp->txbuf, 1);
663 mutex_unlock(&mcp->lock);
668 if (mcp->gpio_dir == MCP2221_DIR_IN)
669 return GPIO_LINE_DIRECTION_IN;
671 return GPIO_LINE_DIRECTION_OUT;
674 /* Gives current state of i2c engine inside mcp2221 */
675 static int mcp_get_i2c_eng_state(struct mcp2221 *mcp,
681 case MCP2221_I2C_WRADDRL_NACK:
682 case MCP2221_I2C_WRADDRL_SEND:
685 case MCP2221_I2C_START_TOUT:
686 case MCP2221_I2C_STOP_TOUT:
687 case MCP2221_I2C_WRADDRL_TOUT:
688 case MCP2221_I2C_WRDATA_TOUT:
691 case MCP2221_I2C_ENG_BUSY:
694 case MCP2221_SUCCESS:
705 * MCP2221 uses interrupt endpoint for input reports. This function
706 * is called by HID layer when it receives i/p report from mcp2221,
707 * which is actually a response to the previously sent command.
709 * MCP2221A firmware specific return codes are parsed and 0 or
710 * appropriate negative error code is returned. Delayed response
711 * results in timeout error and stray reponses results in -EIO.
713 static int mcp2221_raw_event(struct hid_device *hdev,
714 struct hid_report *report, u8 *data, int size)
717 struct mcp2221 *mcp = hid_get_drvdata(hdev);
721 case MCP2221_I2C_WR_DATA:
722 case MCP2221_I2C_WR_NO_STOP:
723 case MCP2221_I2C_RD_DATA:
724 case MCP2221_I2C_RD_RPT_START:
726 case MCP2221_SUCCESS:
730 mcp->status = mcp_get_i2c_eng_state(mcp, data, 2);
732 complete(&mcp->wait_in_report);
735 case MCP2221_I2C_PARAM_OR_STATUS:
737 case MCP2221_SUCCESS:
738 if ((mcp->txbuf[3] == MCP2221_I2C_SET_SPEED) &&
739 (data[3] != MCP2221_I2C_SET_SPEED)) {
740 mcp->status = -EAGAIN;
743 if (data[20] & MCP2221_I2C_MASK_ADDR_NACK) {
744 mcp->status = -ENXIO;
747 mcp->status = mcp_get_i2c_eng_state(mcp, data, 8);
752 complete(&mcp->wait_in_report);
755 case MCP2221_I2C_GET_DATA:
757 case MCP2221_SUCCESS:
758 if (data[2] == MCP2221_I2C_ADDR_NACK) {
759 mcp->status = -ENXIO;
762 if (!mcp_get_i2c_eng_state(mcp, data, 2)
767 if (data[3] == 127) {
771 if (data[2] == MCP2221_I2C_READ_COMPL) {
773 memcpy(&buf[mcp->rxbuf_idx], &data[4], data[3]);
774 mcp->rxbuf_idx = mcp->rxbuf_idx + data[3];
783 complete(&mcp->wait_in_report);
786 case MCP2221_GPIO_GET:
788 case MCP2221_SUCCESS:
789 if ((data[mcp->gp_idx] == MCP2221_ALT_F_NOT_GPIOV) ||
790 (data[mcp->gp_idx + 1] == MCP2221_ALT_F_NOT_GPIOD)) {
791 mcp->status = -ENOENT;
793 mcp->status = !!data[mcp->gp_idx];
794 mcp->gpio_dir = data[mcp->gp_idx + 1];
798 mcp->status = -EAGAIN;
800 complete(&mcp->wait_in_report);
803 case MCP2221_GPIO_SET:
805 case MCP2221_SUCCESS:
806 if ((data[mcp->gp_idx] == MCP2221_ALT_F_NOT_GPIOV) ||
807 (data[mcp->gp_idx - 1] == MCP2221_ALT_F_NOT_GPIOV)) {
808 mcp->status = -ENOENT;
814 mcp->status = -EAGAIN;
816 complete(&mcp->wait_in_report);
821 complete(&mcp->wait_in_report);
827 static int mcp2221_probe(struct hid_device *hdev,
828 const struct hid_device_id *id)
833 mcp = devm_kzalloc(&hdev->dev, sizeof(*mcp), GFP_KERNEL);
837 ret = hid_parse(hdev);
839 hid_err(hdev, "can't parse reports\n");
843 ret = hid_hw_start(hdev, HID_CONNECT_HIDRAW);
845 hid_err(hdev, "can't start hardware\n");
849 ret = hid_hw_open(hdev);
851 hid_err(hdev, "can't open device\n");
855 mutex_init(&mcp->lock);
856 init_completion(&mcp->wait_in_report);
857 hid_set_drvdata(hdev, mcp);
860 /* Set I2C bus clock diviser */
861 if (i2c_clk_freq > 400)
863 if (i2c_clk_freq < 50)
865 mcp->cur_i2c_clk_div = (12000000 / (i2c_clk_freq * 1000)) - 3;
867 mcp->adapter.owner = THIS_MODULE;
868 mcp->adapter.class = I2C_CLASS_HWMON;
869 mcp->adapter.algo = &mcp_i2c_algo;
870 mcp->adapter.retries = 1;
871 mcp->adapter.dev.parent = &hdev->dev;
872 snprintf(mcp->adapter.name, sizeof(mcp->adapter.name),
873 "MCP2221 usb-i2c bridge on hidraw%d",
874 ((struct hidraw *)hdev->hidraw)->minor);
876 ret = i2c_add_adapter(&mcp->adapter);
878 hid_err(hdev, "can't add usb-i2c adapter: %d\n", ret);
881 i2c_set_adapdata(&mcp->adapter, mcp);
883 /* Setup GPIO chip */
884 mcp->gc = devm_kzalloc(&hdev->dev, sizeof(*mcp->gc), GFP_KERNEL);
890 mcp->gc->label = "mcp2221_gpio";
891 mcp->gc->direction_input = mcp_gpio_direction_input;
892 mcp->gc->direction_output = mcp_gpio_direction_output;
893 mcp->gc->get_direction = mcp_gpio_get_direction;
894 mcp->gc->set = mcp_gpio_set;
895 mcp->gc->get = mcp_gpio_get;
896 mcp->gc->ngpio = MCP_NGPIO;
898 mcp->gc->can_sleep = 1;
899 mcp->gc->parent = &hdev->dev;
901 ret = devm_gpiochip_add_data(&hdev->dev, mcp->gc, mcp);
908 i2c_del_adapter(&mcp->adapter);
910 hid_hw_close(mcp->hdev);
912 hid_hw_stop(mcp->hdev);
916 static void mcp2221_remove(struct hid_device *hdev)
918 struct mcp2221 *mcp = hid_get_drvdata(hdev);
920 i2c_del_adapter(&mcp->adapter);
921 hid_hw_close(mcp->hdev);
922 hid_hw_stop(mcp->hdev);
925 static const struct hid_device_id mcp2221_devices[] = {
926 { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_MCP2221) },
929 MODULE_DEVICE_TABLE(hid, mcp2221_devices);
931 static struct hid_driver mcp2221_driver = {
933 .id_table = mcp2221_devices,
934 .probe = mcp2221_probe,
935 .remove = mcp2221_remove,
936 .raw_event = mcp2221_raw_event,
939 /* Register with HID core */
940 module_hid_driver(mcp2221_driver);
942 MODULE_AUTHOR("Rishi Gupta <gupt21@gmail.com>");
943 MODULE_DESCRIPTION("MCP2221 Microchip HID USB to I2C master bridge");
944 MODULE_LICENSE("GPL v2");