Skip to contentSkip to conversation

HID: mcp2200: added driver for GPIOs of MCP2200

PATCH In review Johannes Roith 3 participants 4 messages Sep 21, 2023 – Nov 21, 2023 HID

lore
Share & tools
lore
#0 lore raw

PATCH v7 1/1 HID: mcp2200: added driver for GPIOs of MCP2200

Added a gpiochip compatible driver to control the 8 GPIOs of the MCP2200 by using the HID interface.

Using GPIOs with alternative functions (GP0<->SSPND, GP1<->USBCFG, GP6<->RXLED, GP7<->TXLED) will reset the functions, if set (unset by default).

The driver was tested while also using the UART of the chip. Setting and reading the GPIOs has no effect on the UART communication. However, a reset is triggered after the CONFIGURE command. If the GPIO Direction is constantly changed, this will affect the communication at low baud rates. This is a hardware problem of the MCP2200 and is not caused by the driver.

---
 drivers/hid/Kconfig       |   9 +
 drivers/hid/Makefile      |   1 +
 drivers/hid/hid-ids.h     |   1 +
 drivers/hid/hid-mcp2200.c | 392 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 403 insertions(+)
 create mode 100644 drivers/hid/hid-mcp2200.c
drivers/hid/Kconfig +9 -0
index 0cea301cc9a9..3c14644b593d 100644
@@ -1298,6 +1298,15 @@ 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_MCP2200
+	tristate "Microchip MCP2200 HID USB-to-GPIO bridge"
+	depends on USB_HID && GPIOLIB
+	help
+	  Provides GPIO functionality over USB-HID through MCP2200 device.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called hid-mcp2200.ko.
+
 config HID_MCP2221
 	tristate "Microchip MCP2221 HID USB-to-I2C/SMbus host support"
 	depends on USB_HID && I2C
drivers/hid/Makefile +1 -0
index 8a06d0f840bc..082a728eac60 100644
@@ -79,6 +79,7 @@ obj-$(CONFIG_HID_LOGITECH_HIDPP)	+= hid-logitech-hidpp.o
 obj-$(CONFIG_HID_MACALLY)	+= hid-macally.o
 obj-$(CONFIG_HID_MAGICMOUSE)	+= hid-magicmouse.o
 obj-$(CONFIG_HID_MALTRON)	+= hid-maltron.o
+obj-$(CONFIG_HID_MCP2200)	+= hid-mcp2200.o
 obj-$(CONFIG_HID_MCP2221)	+= hid-mcp2221.o
 obj-$(CONFIG_HID_MAYFLASH)	+= hid-mf.o
 obj-$(CONFIG_HID_MEGAWORLD_FF)	+= hid-megaworld.o
drivers/hid/hid-ids.h +1 -0
index 7e499992a793..bb87ad4eb2aa 100644
@@ -915,6 +915,7 @@
 #define USB_DEVICE_ID_PICK16F1454	0x0042
 #define USB_DEVICE_ID_PICK16F1454_V2	0xf2f7
 #define USB_DEVICE_ID_LUXAFOR		0xf372
+#define USB_DEVICE_ID_MCP2200		0x00df
 #define USB_DEVICE_ID_MCP2221		0x00dd
 
 #define USB_VENDOR_ID_MICROSOFT		0x045e
drivers/hid/hid-mcp2200.c new file +392 -0

392 lines not on this page · raw message

Signature · 1 line
2.42.0
Reviewed-by on v7 1/1
#1 lore raw
Quoted 14 lines · On Thu, 21 Sep, 2023 18:49:28 +0200 "Johannes Roith"…

Added a gpiochip compatible driver to control the 8 GPIOs of the MCP2200 by using the HID interface.

Using GPIOs with alternative functions (GP0<->SSPND, GP1<->USBCFG, GP6<->RXLED, GP7<->TXLED) will reset the functions, if set (unset by default).

The driver was tested while also using the UART of the chip. Setting and reading the GPIOs has no effect on the UART communication. However, a reset is triggered after the CONFIGURE command. If the GPIO Direction is constantly changed, this will affect the communication at low baud rates. This is a hardware problem of the MCP2200 and is not caused by the driver.

Quoted 2 lines

---

#2 lore raw

Dear Maintainers,

my patch has undergone review by Rahul Rameshbabu, and I have addressed the feedback accordingly.

I understand that you all have busy schedules, and I appreciate the time and effort you dedicate to maintaining the Linux kernel. However, I would be grateful if you could provide an update on the patch's status and whether there are any further actions required from my end.

Best regards,
Johannes Roith

maintainer
#3 lore raw
In reply to Johannes Roith
Quoted 7 lines · Johannes Roith

Added a gpiochip compatible driver to control the 8 GPIOs of the MCP2200 by using the HID interface.

Using GPIOs with alternative functions (GP0<->SSPND, GP1<->USBCFG, GP6<->RXLED, GP7<->TXLED) will reset the functions, if set (unset by default).

Quoted 8 lines

The driver was tested while also using the UART of the chip. Setting and reading the GPIOs has no effect on the UART communication. However, a reset is triggered after the CONFIGURE command. If the GPIO Direction is constantly changed, this will affect the communication at low baud rates. This is a hardware problem of the MCP2200 and is not caused by the driver.

Now applied to hid.git#for-6.8/mcp2200. Thanks and sorry for the delay in the review.

Signature · 2 lines
Jiri Kosina
SUSE Labs