Commit Graph

863 Commits

Author SHA1 Message Date
thorpej 4ea2e44bb6 Remove unnecessary include of <sys/malloc.h>. 2024-05-17 23:57:46 +00:00
andvar af0f598536 ihidev(4): make driver compile with ACPI option disabled.
This change unlikely useful in practice, but adds consistency to already
available guards. Driver won't attach currently without ACPI.
2024-04-29 21:25:34 +00:00
andvar c05ba3d507 s/Nuvaton/Nuvoton/ in log message. 2024-02-11 09:20:08 +00:00
andvar 34908c4889 fix various typos in comments. 2024-02-02 22:39:09 +00:00
andvar 80c3ddc607 Fix typos in word "particularly", in comments. 2024-01-16 21:08:52 +00:00
mlelstv 82249e7b1d Output is always 16bit, the internal audio data type may differ. 2023-12-11 13:27:24 +00:00
riastradh 092cbeea82 ihidev(4): Use iic_use_direct_match as intended.
This appears to have been a mistake; there's no obvious explanation
in the commit history for why this is different from all other
iic_use_direct_match users.

Patch from Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>, thanks!

(If it really is intended to ues I2C_MATCH_DIRECT_COMPATIBLE here, we
need a clear explanation of why, written down in a nearby comment.)
2023-08-01 19:36:45 +00:00
riastradh 0e28bc09c1 ims(4): Use config_detach_children. 2023-05-10 00:10:02 +00:00
mlelstv 5b85cc1295 Don't panic with invalid user data, just return an error. 2023-01-24 07:09:48 +00:00
andvar ed25b58060 fix typos in comments. 2023-01-23 22:20:59 +00:00
brad 50bb9ed19f Split the BMP280 / BME280 driver into common code and create I2C and
SPI attachments.
2022-12-03 01:04:42 +00:00
brad dbe003da84 Use a better choice for the print format string. 2022-12-01 02:29:37 +00:00
brad 7f9418aa5b Correct the humidity conversion for the BME280 2022-12-01 00:47:51 +00:00
brad 4f697dfb7c Mention where in the datasheet the compensation algorithms came from. 2022-11-24 21:07:05 +00:00
brad e2526a7b7a Use kpause() instead of delay() in the measurement cycle. Try and
derive the proper wait delay for the measurement based upon the over
sampling setting and allow the wait factor multiplier to be adjusted.
2022-11-23 23:45:29 +00:00
brad cc376c7e6d Read the datasheet more closely and put in some delays. The chip will
just return junk if the wait is not long enough to allow a measurement
to start.
2022-11-22 19:40:31 +00:00
brad 068b504f95 A driver for the Bosch BMP280 / BME280 temperature, humidity and
atmospheric pressure sensor.  This is an inexpensive to moderately
expensive chip available from a large number of places.  The driver
supports all aspects of the two chips, except for the repeating read
mode which would allow for sub-second queries, such as fall detection
or perhaps even as an altimeter.  This driver also only supports the
I2C interface and not the SPI interface.

The BME280, the one with humidity, is not fully tested at this point,
awaiting upon a breakout board and may not show proper humidity.
2022-11-21 21:24:00 +00:00
brad 50bf6d2dfd A driver for the Aosong AHT20 temperature and humidity sensor. While
slow for an I2C sensor it is inexpensive and should work well enough
in most indoor conditions.  All features of the chip are supported.
2022-11-17 19:20:05 +00:00
jmcneill ee5caec1b4 Add GPIO support.
PR# kern/57030
2022-10-30 11:51:19 +00:00
riastradh 74fe5a0735 iic(4): Use config_detach_children to simplify. 2022-10-24 10:17:40 +00:00
riastradh c12151368a i2c(9): Nix smbus intr API.
It was introduced in 2007 for some Xbox thing which was removed in
2011.  The API and the threads it spawned have been sitting around
idly for over a decade serving no purpose -- sometimes causing kernel
lock spinouts in the event of panic.

Add ic_tag_private to obviate need for future ABI changes.  Not
currently used, but we can privately allocate memory in iic_tag_init
for the purpose later if need be without changing ABI.

XXX kernel revbump -- changes struct i2c_controller
2022-10-24 10:17:27 +00:00
andvar 9cc225e6d6 s/inerrupt/interrupt/ and s/intrrupt/interrupt/ in comments. 2022-09-25 12:41:46 +00:00
thorpej fa87d2aa12 If there is a compat string list, parenthetically print the first one
in iic_print_direct().  (From thorpej-i2c-spi-conf2 branch.)
2022-07-23 03:05:27 +00:00
thorpej 66fba52e46 Normalize how motoi2c controllers are attached. 2022-07-22 23:43:23 +00:00
thorpej a441e7a25d Improve error reporting. 2022-07-20 22:58:35 +00:00
riastradh 99d298e068 drm: Use CPPFLAGS.drmkms in all local drm drivers too.
This way we don't pollute the NetBSD kernel namespace with all the
Linux compat shim definitions needed to build drm, except for the
local drm drivers that need the API.
2022-07-20 10:01:10 +00:00
andvar da132425bb s/tempurature/temperature/ 2022-07-02 16:28:39 +00:00
mlelstv 1b94a9f4b2 Bump max transaction size from 32 Bytes to 4kB. 2022-06-29 15:34:15 +00:00
mlelstv 0c103aaf57 Allocate data buffer instead of using the stack. 2022-06-29 15:33:45 +00:00
andvar 114b022676 fix various typos in comments. 2022-05-28 22:16:43 +00:00
andvar 86c307248f fix various typos, mainly in comments. 2022-05-28 10:36:21 +00:00
andvar 9f4a9600be fix various typos in comments, docs and log messages. 2022-05-24 06:27:59 +00:00
andvar f42f89fd6f fix various small typos, mainly in comments. 2022-05-22 11:27:33 +00:00
brad 4e93751222 After testing with a couple of more samples of the SHT3x sensor chip
it was found that the datasheet does not appear to provide enough
information to make use of the alarm and interrupt function work.  So
actually remove the dead code that was an attempt at making that all
work.  Adjust the man page to mention that this.
2022-04-27 23:11:25 +00:00
pgoyette 7694d68911 Split i2c_subr.c into a separate module rather than including it in
the iic module.  There are valid configurations where i2c_subr code
can be both built-in and part of a loaded module (eg, piixpm is in
the kernel, but the iic module is loaded later).  This causes the
in-kernel linker to detect a duplicate symbol.
2022-04-01 15:49:11 +00:00
pgoyette 97f8debd62 For device modules that provide both auto-config and /dev/xxx
interfaces, make sure that initialization and destruction
follow the proper sequence.  This is triggered by the recent
changes to the devsw stuff; per riastradh@ the required call
sequence is:

	devsw_attach()
	config_init_component() or config_cf*_attach()
	...
	config_fini_component() or config_cf*_detach()
	devsw_detach()

While here, add a few missing calls to some of the detach
routines.

Testing of these changes has been limited to:
	1. compile without build break
	2. no related test failures from atf
	3. modload/modunload work as well as
	   before.

No functional device testing done, since I don't have any
of these devices.  Let me know of any damage I might cause
here!

XXX Some of the modules affected by this commit are already
XXX broken;  see kern/56772.  This commit does not break
any additional modules (as far as I know).
2022-03-31 19:30:15 +00:00
pgoyette a02f62015b These modules need to depend on iic, not just on i2cexec. (They will
still recursively get i2cexec since the iic depends on it.)

Partial fix for kern/56772
2022-03-30 00:06:50 +00:00
riastradh e7bed28911 driver(9): devsw_detach never fails. Make it return void.
Prune a whole lotta dead branches as a result of this.  (Some logic
calling this is also wrong for other reasons; devsw_detach is final
-- you should never have any reason to decide to roll it back.  To be
cleaned up in subsequent commits...)

XXX kernel ABI change to devsw_detach signature requires bump
2022-03-28 12:33:20 +00:00
riastradh 3aa5a3ae30 sys: Fix various abuse of struct device internals.
Will help to make struct device opaque later.
2022-02-12 03:24:34 +00:00
andvar 34df0b3791 remove double "with" in comments and usage text. Also fix one typo. 2022-01-24 09:42:13 +00:00
thorpej 3944ff70a4 Change the devhandle_from_*() functions to also take a "super handle",
from which the newly created handle will inherit it's implementation.
The root implementation for a new handle type is used if an invalid
"super handle" is passed.
2022-01-22 11:49:16 +00:00
thorpej 4645780005 Replace devhandle_invalidate(), which invalidates a devhandle, with
devhandle_invalid(), which returns an invalid devhandle.
2022-01-21 15:55:36 +00:00
thorpej aa7530e36b G/C mcpgpio_softc::sc_phandle; nothing is using it. 2022-01-17 19:36:54 +00:00
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