Commit Graph

820 Commits

Author SHA1 Message Date
thorpej e2da7dc983 Minimal hack to pass child devices a devhandle created from the OF
or ACPI "cookie".  Temporary measure until the i2c autoconfiguration
overhaul is merged (which fixes this in a more generic way).
2022-01-17 19:34:31 +00:00
thorpej 5eb438ad7a Re-factor and overhaul the "mcp23s17gpio" driver as "mcpgpio", and
add support for 8-bit and I2C variants of the chip:
- MCP23008 / MCP23S08: 8-bit (I2C / SPI)
- MCP23017 / MCP23S17: 16-bit (I2C / SPI)
- MCP23018 / MCP23S18: 16-bit (I2C / SPI), open-drain outputs

The MCP23x17 and MCP23x18 are essentially identical, software-wise; we
merely report different GPIO pin capabilities (no push-pull output for
MCP23x18).  Also, remove the tri-state capability that was previously
advertised by the old version of this driver; these chips have no way
to put the pin into a HI-Z mode.

All 3 I2C versions are supported, but the SPI front-end still only
supports the MCP23S17 for now (SPI autoconfiguration needs an overhaul).

mcp23s17gpio(4) remains present as a link to the new mcpgpio(4) man page.

XXX Still to-do: FDT integration, interrupt suppoort.
2022-01-17 16:31:23 +00:00
skrll 65476283f7 Trailing whitespace 2022-01-15 06:22:30 +00:00
riastradh 3b602431c5 ihidev(4): Prohibit closing an unopened ihidev. 2022-01-14 22:28:59 +00:00
riastradh 0aca25b218 ihidev(4): Avoid reference count overflow. 2022-01-14 22:28:50 +00:00
riastradh 7b92ccfd50 ims(4): Sprinkle KERNEL_LOCKED_P assertions.
Access to the softc and hidms state is currently kernel-locked.
2022-01-14 22:28:42 +00:00
riastradh 9a6f5d0651 ihidev(4): Take the lock for ihidev_open, ihidev_close.
Need this to serialize access to sc_state, sc_refcnt.

XXX Should harmonize this with uhidev(4) and tighten assertions.
2022-01-14 22:28:23 +00:00
riastradh 37f4183882 ihidev(4): Check kmem_alloc(..., KM_NOSLEEP) for failure. 2022-01-14 22:26:45 +00:00
riastradh 060cca7953 ihidev(4): Allocate report buffer with KM_SLEEP.
Limited to 64k and only happens on attach anyway.  Let's not leave a
rake to trip on here.
2022-01-14 22:26:35 +00:00
riastradh be765157c3 ihidev(4): Fix locking and interrupt handler.
- Can't run iic_exec in softint because it does cv_wait, at least on
  some i2c controllers -- defer to workqueue instead.

- Fix violations of locking rules:
  . Do not take a lock at higher IPL than it is defined at!
  . Do not sleep under a lock!
  . Definitely do not sleep under a spin lock!
  In this case, sc_intr_lock was defined at IPL_VM but used at IPL_TTY,
  and i2c transactions -- possibly causing sleep for cv_wait -- were
  issued under it.

  But in this case, the interrupt handler needs only a single bit to
  mark whether the work is pending, so just use atomic_swap for that.

- Use an adaptive lock (IPL_NONE) for i2c transactions.

- Detach children, and do so before freeing anything.
2022-01-14 22:25:49 +00:00
riastradh 4683132b0e ihidev(4): Add missing includes and header guard.
Mark the sections that are conventionally separate files for hardware
interface (*reg.h) versus software state (*var.h).
2022-01-14 21:32:27 +00:00
andvar c54cdfdc0c fix few typos in comments. 2021-12-27 23:04:19 +00:00
riastradh d86ac1745c drm: Fix tda19988 drm build. 2021-12-19 12:44:34 +00:00
riastradh dd47db3e83 Sort includes. 2021-12-19 11:01:10 +00:00
riastradh 3973e774e2 Get drm to build on arm64 again.
Author: Jared McNeill <jmcneill@NetBSD.org>
Committer: Taylor R Campbell <riastradh@NetBSD.org>
2021-12-19 11:00:46 +00:00
brad bf53d44167 A driver and user land utility for the Sparkfun Serial Controlled Motor
Driver module as illustrated here:

https://www.sparkfun.com/products/13911

A SCMD module is a ARM SOC simular to a Arduino in front of a motor
driver chip.  The single SCMD module can control two motors and up to
16 additional modules can be chained together using an internal I2C
bus.  One can interface with the SCMD using tty uart commands, SPI or
I2C.  The driver in this commit adds a kernel driver for the I2C and
SPI interfaces.  The command line utility provides a set of
convenience commands that support most of the functions of the SCMD
and is able to use the tty uart mode, SPI user land or the included
kernel driver in a uniform manor.

The use of the SCMD module is mostly for small robots and the like,
but it can control anything that is controllable by voltage.
2021-12-07 17:39:53 +00:00
msaitoh 2317530af9 Check the return value correctly. Pointed out by pgoyette@. 2021-12-06 16:24:57 +00:00
msaitoh f45c2bb411 Carefully access to the I2C bus in the match function. 2021-12-06 04:25:36 +00:00
msaitoh 1e8046cad5 Use aprint_debug instead of aprint_error for expected failure. 2021-12-01 21:33:19 +00:00
msaitoh 401cbd3c28 Access byte2... 2021-11-30 05:02:29 +00:00
brad d4c7397f98 Fix some regressions that were introduced.
One must make sure that you release the i2c bus if you acquire.

One must not try to release the i2c bus if you failed to acquire it.

One can't leave too early from the single-shot refresh without
checking the status register as there may have been a reset
and releasing the i2c bus.
2021-11-14 18:36:13 +00:00
christos 77a9e52f32 Brad wants the __did_not_work code back :-) 2021-11-13 13:36:42 +00:00
christos ecf8833b75 simplify the code and remove unused (it is in CVS anyway). Try to merge
duplicate code. Follow KNF. Brad, please test!
2021-11-12 22:16:27 +00:00
brad d8ba40df01 Fix the serial number handling of the HTU21D chip and probably others.
Increase the number of read attempts as the HTU21D and probably others
do not respond as fast the actual SI70xx chip can.
2021-11-12 15:12:11 +00:00
brad d0247a8a52 Some HTU21D chips do not have a heater register and apparently no
heater element.  Disable the heater features in the driver when that
condition is detected and let the attachment succeed.  Also mention
that the SHT21 is another clone.
2021-11-11 14:16:04 +00:00
msaitoh 50f18f7158 s/acutal/actual/ in comment. 2021-11-10 15:39:03 +00:00
jmcneill 4d50866df0 cwfg: update for dts-5.15 binding changes 2021-11-07 17:14:38 +00:00
brad 1f3d8cb8fe Driver for the Sensirion SHT30/SHT31/SHT35 temperature and humidity
sensor such as:

https://www.adafruit.com/product/2857

This is a higher priced sensor with a lot of features, including the
ability to do sub-second periodic updates.  The driver supports
everything about the sensor except for the alert pin.
2021-11-06 13:34:39 +00:00
brad f1dc69bc34 Correct an off by one degree error in the temperature conversion. 2021-10-29 23:23:33 +00:00
christos 6ee69a7778 - fix clang compilation: add "%s" to format string
- comma is followed by space
- KNF multi-line comments
- fold long lines
- early returns, fixes a missed iic_release_bus() on error.
- foo == false -> !foo
2021-10-20 17:52:44 +00:00
christos ef513097b6 Fix llvm build: error: equality comparison with extraneous parentheses
[-Werror,-Wparentheses-equality]
2021-10-18 14:14:07 +00:00
brad ea034c40cb A driver for the Sensirion SGP40 MOx gas sensor. An example of this
chip from Adafruit is:

https://www.adafruit.com/product/4829

This is a moderately priced gas sensor that can detect volatile
organic compounds in the air.  The driver uses the 3-clause BSD
licensed VOC algorithm provided by Sensirion to turn the raw sensor
metric into a VOC index which can indicate the quality of the air in a
particular indoor environment.  All published functions of the chip
are supported and one unpublished feature.
2021-10-14 13:54:45 +00:00
andvar de4fa9d769 fix various typos, mainly in comments. 2021-10-12 08:36:28 +00:00
brad ee2dd9d79d A driver for the Sensirion SHT40/SHT41/SHT45 temperature and humidity
sensor.  An example of this chip is:

https://www.adafruit.com/product/4885

This is a lower cost chip that provides higher then usual precision
according to the data sheet.  This driver supports all of the published
functions that the chip has.
2021-10-03 17:27:02 +00:00
andvar 8324be4c9b fix some more typos in comments/log messages, improve wording as well. 2021-08-21 11:55:24 +00:00
andvar 6584ea569e fix various typos in compatibility, mainly in comments. 2021-08-09 20:49:08 +00:00
thorpej c7fb772b85 Merge thorpej-cfargs2. 2021-08-07 16:18:40 +00:00
tnn 2e6662efc3 ssdfb: revert rev 1.14
Can't run the worker thread MPSAFE with spi(4) yet because most controller
drivers still lack MP safety. Cause issues when using multiple displays.
2021-08-05 22:31:20 +00:00
andvar d42188d8bf Fix various typos in comments. Also add missing NetBSD RCS Id in some of these files. 2021-08-03 23:12:14 +00:00
tnn 4b00815e3d ssdfb(4): remove code for dealing with non-MPSAFE attachment
spi(4) was marked MPSAFE some time ago, so we're always on an
MPSAFE parent device.
2021-07-30 13:44:09 +00:00
macallan 2282ff73b6 move the fcu driver into arch/macppc where it belongs 2021-07-27 20:23:41 +00:00
macallan f83944e0d2 don't put CPUs in separate zones, turns out there really isn't much that
keeps the airflow apart around them
2021-07-25 00:11:43 +00:00
christos 3151045394 fix proplib deprecation 2021-06-21 03:04:27 +00:00
mlelstv da3ac36bae iic_acquire_bus may fail. 2021-06-15 04:41:01 +00:00
mlelstv 2bcef4d56c avoid double-free 2021-06-15 04:39:49 +00:00
jdc 1e4ed9cf7e Call sysmon_envsys_destroy() if we receive any error from sysmon, rather
than just on some errors.
2021-06-14 13:52:11 +00:00
mlelstv cfac8f4e47 Avoid double free when attach fails. 2021-06-14 09:56:04 +00:00
mlelstv 77c8c4e671 iic_acquire_bus can fail 2021-06-13 09:48:04 +00:00
mlelstv 65c5d463c9 Clear sc_sme pointer to avoid double free. 2021-06-13 09:47:36 +00:00
mlelstv 3944730ede iic_acquire_bus can fail. 2021-06-13 09:46:04 +00:00