hid-mcp2200: added driver for GPIOs of MCP2200
PATCH v4 1/1 hid-mcp2200: added driver for GPIOs of MCP2200
From: Johannes Roith <[email protected]>
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.
Feedback from reviewers Christophe JAILLET <[email protected]> and Andi Shyti <[email protected]> was added.
Changelog:
- v1: added driver
- v2: added ProductID in hid-ids.h
- v3: added feedback from review and make patch compilable
- v4: added more feedback from second review, tested as module and buildin on x86 and arm64
--- drivers/hid/Kconfig | 10 + drivers/hid/Makefile | 1 + drivers/hid/hid-ids.h | 1 + drivers/hid/hid-mcp2200.c | 419 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 431 insertions(+) create mode 100644 drivers/hid/hid-mcp2200.c
drivers/hid/Kconfig +10 -0
@@ -1301,6 +1301,16 @@ config HID_MCP2221 To compile this driver as a module, choose M here: the module will be called hid-mcp2221.ko. +config HID_MCP2200 + tristate "Microchip MCP2200 HID USB-to-GPIO bridge" + depends on USB_HID + imply 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_KUNIT_TEST tristate "KUnit tests for HID" if !KUNIT_ALL_TESTS depends on KUNIT
drivers/hid/Makefile +1 -0
@@ -79,6 +79,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_MCP2221) += hid-mcp2221.o +obj-$(CONFIG_HID_MCP2200) += hid-mcp2200.o obj-$(CONFIG_HID_MAYFLASH) += hid-mf.o obj-$(CONFIG_HID_MEGAWORLD_FF) += hid-megaworld.o obj-$(CONFIG_HID_MICROSOFT) += hid-microsoft.o
drivers/hid/hid-ids.h +1 -0
@@ -914,6 +914,7 @@#define USB_DEVICE_ID_PICK16F1454_V2 0xf2f7#define USB_DEVICE_ID_LUXAFOR 0xf372#define USB_DEVICE_ID_MCP2221 0x00dd +#define USB_DEVICE_ID_MCP2200 0x00df#define USB_VENDOR_ID_MICROSOFT 0x045e#define USB_DEVICE_ID_SIDEWINDER_GV 0x003b
drivers/hid/hid-mcp2200.c new file +419 -0
419 lines not on this page · raw message
Signature · 1 line
2.41.0
Hi--
Quoted 8 lines · On 8/17/23 02:15, [email protected] wrote:
drivers/hid/Kconfig +0
-0@@ -1301,6 +1301,16 @@ config HID_MCP2221 To compile this driver as a module, choose M here: the module will be called hid-mcp2221.ko.
drivers/hid/Kconfig config HID_MCP2221 · line 1313
Quoted 10 lines
drivers/hid/Kconfig +10
-0+config HID_MCP2200 + tristate "Microchip MCP2200 HID USB-to-GPIO bridge" + depends on USB_HID + imply 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. +
Please follow coding-style.rst for Kconfig files, copied here with an example:
10) Kconfig configuration files
-------------------------------
For all of the Kconfig* configuration files throughout the source tree, the indentation is somewhat different. Lines under a ``config`` definition are indented with one tab, while help text is indented an additional two spaces. Example::
config AUDIT
bool "Auditing support"
depends on NET
help
Enable auditing infrastructure that can be used with another kernel subsystem, such as SELinux (which requires this for logging of avc messages output). Does not do system-call auditing without CONFIG_AUDITSYSCALL.
drivers/hid/Kconfig config HID_MCP2221 · line 1316
Quoted 3 lines
drivers/hid/Kconfig +0
-0config HID_KUNIT_TEST tristate "KUnit tests for HID" if !KUNIT_ALL_TESTS depends on KUNIT
thanks.
Signature · 1 line
~Randy
kernel test robot
build botkernel test robot noticed the following build warnings:
Hi,
kernel test robot noticed the following build warnings:
[auto build test WARNING on hid/for-next]
[also build test WARNING on linus/master v6.5-rc6 next-20230817] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/johannes-gnu-linux-rocks/hid-mcp2200-added-driver-for-GPIOs-of-MCP2200/20230817-172246 base: https://git.kernel.org/pub/scm/linux/kernel/git/hid/hid.git for-next patch link: https://lore.kernel.org/r/20230817091505.213318-1-johannes%40gnu-linux.rocks patch subject: [PATCH v4] hid-mcp2200: added driver for GPIOs of MCP2200 config: sparc-allyesconfig (https://download.01.org/0day-ci/archive/20230818/[email protected]/config) compiler: sparc64-linux-gcc (GCC) 12.3.0 reproduce: (https://download.01.org/0day-ci/archive/20230818/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
drivers/hid/hid-mcp2200.c: In function 'mcp2200_remove':
>> drivers/hid/hid-mcp2200.c:395:25: warning: variable 'mcp' set but not used [-Wunused-but-set-variable]
395 | struct mcp2200 *mcp;
| ^~~vim +/mcp +395 drivers/hid/hid-mcp2200.c
392
393 static void mcp2200_remove(struct hid_device *hdev)
394 {
> 395 struct mcp2200 *mcp;
396
397 mcp = hid_get_drvdata(hdev);
398 }
399
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki