HID: mcp2221: add usb to i2c-smbus host bridge driver
Rishi Gupta
maintainercover HID: mcp2221: add usb to i2c-smbus host bridge driver
MCP2221 is a USB HID to I2C/SMbus host bridge device. This commit implements i2c and smbus host adapter support. 7-bit address and i2c multi-message transaction is also supported.
Different transactions have been tested with various common hardwares, linux driver and user space tools.
Host PC communicates with mcp2221a over usb using raw hid protocol. Reports are exchanged using interrupt end points. Command and responses are mcp2221a specific and documented in datasheet:
http://ww1.microchip.com/downloads/en/DeviceDoc/20005565B.pdf
There is only 1 patch in this driver submission.
Rishi Gupta (1):
HID: mcp2221: add usb to i2c-smbus host bridge driver
drivers/hid/Kconfig | 10 + drivers/hid/Makefile | 1 + drivers/hid/hid-ids.h | 1 + drivers/hid/hid-mcp2221.c | 773 ++++++++++++++++++++++++++++++++++++++++++++++ drivers/hid/hid-quirks.c | 3 + 5 files changed, 788 insertions(+) create mode 100644 drivers/hid/hid-mcp2221.c
Signature · 1 line
2.7.4
Rishi Gupta
maintainerPATCH 1/1 HID: mcp2221: add usb to i2c-smbus host bridge driver
MCP2221 is a USB HID to I2C/SMbus host bridge device. This commit implements i2c and smbus host adapter support. 7-bit address and i2c multi-message transaction is also supported.
--- drivers/hid/Kconfig | 10 + drivers/hid/Makefile | 1 + drivers/hid/hid-ids.h | 1 + drivers/hid/hid-mcp2221.c | 773 ++++++++++++++++++++++++++++++++++++++++++++++ drivers/hid/hid-quirks.c | 3 + 5 files changed, 788 insertions(+) create mode 100644 drivers/hid/hid-mcp2221.c
drivers/hid/Kconfig +10 -0
@@ -1145,6 +1145,16 @@ config HID_ALPS Say Y here if you have a Alps touchpads over i2c-hid or usbhid and want support for its special functionalities. +config HID_MCP2221 + tristate "Silicon Labs MCP2221 HID USB-to-I2C/SMbus host support" + depends on USB_HID && HIDRAW && I2C + ---help--- + Provides I2C host adapter functionality over USB through MCP2221 + from Silicon Labs. I2C bus speed can be set during driver loading. + + To compile this driver as a module, choose M here: the module + will be called hid-mcp2221.ko. + endmenu endif # HID
drivers/hid/Makefile +1 -0
@@ -71,6 +71,7 @@ obj-$(CONFIG_HID_MACALLY) += hid-macally.o obj-$(CONFIG_HID_MAGICMOUSE) += hid-magicmouse.o obj-$(CONFIG_HID_MALTRON) += hid-maltron.o obj-$(CONFIG_HID_MAYFLASH) += hid-mf.o +obj-$(CONFIG_HID_MCP2221) += hid-mcp2221.o obj-$(CONFIG_HID_MICROSOFT) += hid-microsoft.o obj-$(CONFIG_HID_MONTEREY) += hid-monterey.o obj-$(CONFIG_HID_MULTITOUCH) += hid-multitouch.o
drivers/hid/hid-ids.h +1 -0
@@ -819,6 +819,7 @@#define USB_DEVICE_ID_PICK16F1454 0x0042#define USB_DEVICE_ID_PICK16F1454_V2 0xf2f7#define USB_DEVICE_ID_LUXAFOR 0xf372 +#define USB_DEVICE_ID_MCP2221 0x00dd#define USB_VENDOR_ID_MICROSOFT 0x045e#define USB_DEVICE_ID_SIDEWINDER_GV 0x003b
drivers/hid/hid-mcp2221.c new file +773 -0
773 lines not on this page · raw message
drivers/hid/hid-quirks.c +3 -0
@@ -473,6 +473,9 @@ static const struct hid_device_id hid_have_special_driver[] = { { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_DRAGONRISE_GAMECUBE1) }, { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_DRAGONRISE_GAMECUBE2) }, #endif +#if IS_ENABLED(CONFIG_HID_MCP2221) + { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_MCP2221) }, +#endif #if IS_ENABLED(CONFIG_HID_MICROSOFT) { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_COMFORT_MOUSE_4500) }, { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_COMFORT_KEYBOARD) },
Signature · 1 line
2.7.4
kbuild test robot
build botThank you for the patch! Perhaps something to improve:
Hi Rishi,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on linus/master]
[also build test WARNING on v5.5-rc7 next-20200117]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Rishi-Gupta/HID-mcp2221-add-usb-to-i2c-smbus-host-bridge-driver/20200120-133043 base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git def9d2780727cec3313ed3522d0123158d87224d reproduce: # apt-get install sparse # sparse version: v0.6.1-131-g22978b6b-dirty make ARCH=x86_64 allmodconfig make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'
If you fix the issue, kindly add following tag
sparse warnings: (new ones prefixed by >>)
>> drivers/hid/hid-mcp2221.c:397:5: sparse: sparse: symbol 'mcp_smbus_xfer' was not declared. Should it be static?
Please review and possibly fold the followup patch.
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/[email protected] Intel Corporation
kbuild test robot
build bot[RFC PATCH] HID: mcp2221: mcp_smbus_xfer() can be static
In reply to Rishi GuptaFixes: 38f8a303aca6 ("HID: mcp2221: add usb to i2c-smbus host bridge driver")
--- hid-mcp2221.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/hid-mcp2221.c +1 -1
@@ -394,7 +394,7 @@ static int mcp_smbus_write(struct mcp2221 *mcp, u16 addr,return ret; } -int mcp_smbus_xfer (struct i2c_adapter *adapter,u16 addr, +static int mcp_smbus_xfer (struct i2c_adapter *adapter,u16 addr,unsigned short flags,char read_write,u8 command,int size,union i2c_smbus_data *data)