History log of /src/sys/dev/usb/umcpmio.c |
Revision | | Date | Author | Comments |
1.7 |
| 15-Sep-2025 |
thorpej | Encapsulate what's needed to attach an I2C bus into a iicbus_attach() inline.
|
1.6 |
| 02-Apr-2025 |
riastradh | branches: 1.6.4; umcpmio(4): Make the error case a branch, not the success case.
|
1.5 |
| 31-Mar-2025 |
brad | Break out for a couple of error branches, don't ignore an error when putting flash configs.
Thanks riastradh@netbsd.org
|
1.4 |
| 25-Mar-2025 |
riastradh | umcpmio(4): Omit needless boolean `takemutex' parameter.
This is generally a questionable pattern and it's wholly unnecessary here.
|
1.3 |
| 25-Mar-2025 |
riastradh | umcpmio(4): Linearize error branch structure.
This dramatically reduces the unnecessary indentation of success cases and puts error messages adjacent to the conditions they report.
Rewriting it this way reveals that two of the error branches in umcpmio_dev_read are probably wrong -- should probably break out of the loop, not continue it. To be fixed in a separate commit.
No functional change intended.
|
1.2 |
| 17-Mar-2025 |
riastradh | umcpmio(4): Fix a lot of KNF issues.
- Space after comma. - Space between _keyword_ and parentheses: `for (...)' - No space between _function_ and parentheses: `foo(...)'. - Space around assignment operators: `x = y', not `x=y'. - Space after semicolons: `for (x = 0; x < n; x++)' - Break overlong lines. - Sort includes. - `do { ... } while (0)' in statement macros. - Parenthesize macro arguments (or just use functions if macros aren't necessary). - No parentheses needed for `return': say `return EINVAL;', not `return (EINVAL);' (but parenthesizing complex expressions is fine). - Various other things.
/* * block comments like this */
Please, folks, read through /usr/share/misc/style and try to adhere to it _before_ committing. There's also an Emacs C style in /usr/share/misc/NetBSD.el and a clang-format configuration in /usr/share/misc/dot.clang-format to help you.
Aside from KNF, I strongly encourage you to write:
error = foo(); if (error) goto out; error = bar(); if (error) goto out; ...
instead of
error = foo(); if (!error) { error = bar(); if (!error) { ... } else { printf("error in bar\n"); } } else { printf("error in foo\n"); }
It's hard to follow _both_ the success cases _and_ the failure cases when the success cases grow progressively more deeply indented, and the failure cases are farther and farther away from the logic handling them as you have more conditions.
|
1.1 |
| 16-Dec-2024 |
brad | A driver for the MCP-2221 / 2221A multi-io chip. This is a USB to UART / GPIO / I2C multi-io chip probably based upon a programmed PIC. The end result is that simple gpio and i2c can exist on any system that provides a USB port. This is everything from a RPI to a Virtualbox VM.
o The UART presents itself as a umodem(4) device and pretty much works as one would expect.
o There are 4 simple GPIO pins with multiple functions that attach to gpio(4). Support for basic GPIO input and output exists with gpioctl, the ADC, DAC and clock pulse functions exist as ALT functions. For the ADC and DAC /dev/ devices are provided such that simple reads and writes interact with the ADC and DAC. The IRQ function on pin GP1 and bit banging the GPIO with gpiopps(4) and gpioow(4) are not really supported. The short answer is that a spin lock is held while trying to do USB transfers and that isn't allowed.
o There is a simple I2C engine that attaches to iic(4). This mostly works as expected, except that a READ without STOP is not supported by the engine which causes problems for some drivers. Most drivers do not seem to use READ without STOP and seem to work as expected. Support for changing the I2C speed is not supported, but nothing much really does that.
o A userland utility called umcpmioctl(8) is provided that allows the query of the status of the chip and allows for the query of the flash memory and the setting of some of the flash memory parameters mostly related to gpio. This utility interacts with a control device in /dev/. The flash memory contents is copied to the sram on boot up of the chip and can be used to adjust how the chip sets up the gpio pins, among other things. Support for setting or entering the chip password is not provided.
o A number of sysctls are provided to mess with various settings. These are detailed in the man page.
While not perfect, the chip is reasonable, cheap, and has at least one vendor making a breakout board. It is also one of the only ones in this space that has enough documentation to write a driver.
Support for a related chip, the MCP-2210, which provides SPI and GPIO may exist some day as the programming interface is very simular.
|
1.6.4.2 |
| 02-Aug-2025 |
perseant | Sync with HEAD
|
1.6.4.1 |
| 02-Apr-2025 |
perseant | file umcpmio.c was added on branch perseant-exfatfs on 2025-08-02 05:57:06 +0000
|