cp2112: driver for the namesake GPIO and I2C master gadget

Documentation:
- CP2112 Datasheet
  https://www.silabs.com/documents/public/data-sheets/cp2112-datasheet.pdf
- AN495: CP2112 Interface Specification
  https://www.silabs.com/documents/public/application-notes/an495-cp2112-interface-specification.pdf
- CP2112 Errata
  https://www.silabs.com/documents/public/errata/cp2112-errata.pdf

The logic is implemented as three sub-drivers.
The parent driver claims the USB device and creates two child devices.
One acts as a GPIO controller and the other is an I2C controller.

Tested with CP2112 revision F02.
Both features seem to work.
HTU21 sensor was used as an I2C slave.

Reviewed by:	adrian, hselasky
MFC after:	2 weeks
Relnotes:	maybe
Differential Revision: https://reviews.freebsd.org/D25359
This commit is contained in:
Andriy Gapon
2020-08-06 13:41:42 +00:00
parent 0736ad87b9
commit c178a7e73c
4 changed files with 1420 additions and 0 deletions
+1
View File
@@ -3331,6 +3331,7 @@ dev/usb/serial/usb_serial.c optional ucom | u3g | uark | ubsa | ubser | \
#
# USB misc drivers
#
dev/usb/misc/cp2112.c optional cp2112
dev/usb/misc/ufm.c optional ufm
dev/usb/misc/udbp.c optional udbp
dev/usb/misc/ugold.c optional ugold
File diff suppressed because it is too large Load Diff
+1
View File
@@ -50,6 +50,7 @@ SUBDIR += ${_rum} ${_run} ${_runfw} ${_uath} upgt usie ural ${_zyd} ${_urtw}
SUBDIR += atp cfumass uhid uhid_snes ukbd ums udbp ufm uep wmt wsp ugold uled
SUBDIR += ucom u3g uark ubsa ubser uchcom ucycom ufoma uftdi ugensa uipaq ulpt \
umct umcs umodem umoscom uplcom uslcom uvisor uvscom
SUBDIR += cp2112
SUBDIR += udl
SUBDIR += uether aue axe axge cdce cdceem cue ${_kue} mos rue smsc udav uhso \
ipheth
+37
View File
@@ -0,0 +1,37 @@
#
# $FreeBSD$
#
# Copyright (c) Andriy Gapon <avg@FreeBSD.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
S= ${SRCTOP}/sys
.PATH: $S/dev/usb/misc
KMOD= cp2112
SRCS= cp2112.c
SRCS+= opt_bus.h opt_usb.h
SRCS+= device_if.h bus_if.h gpio_if.h iicbus_if.h usb_if.h usbdevs.h
.include <bsd.kmod.mk>