Commit Graph

863 Commits

Author SHA1 Message Date
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
skrll e1af757616 Bail out of axpreg_attach if axpreg_get_voltage returns an error.
uvol isn't updated and shouldn't be used.
2021-05-24 05:58:42 +00:00
macallan 762a14e590 add \n to attach output 2021-05-21 21:21:01 +00:00
macallan 16af3cfd56 don't prop_object_retain(NULL) 2021-05-21 20:42:05 +00:00
thorpej 2685996b0e Merge thorpej-cfargs branch:
Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
  actually needed.
- Don't be explicit about what interface attribute is attaching if
  the device only has one.  (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
  situations, making is visibly easier to see when indirect config is
  in play, and allowing for future change in semantics.  (As of now,
  this is just a wrapper around config_match(), but that is an
  implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance.  This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
2021-04-24 23:36:23 +00:00
skrll b6f5691d57 spello in comment 2021-04-16 07:02:09 +00:00
rin 55daaba23c Use lmtemp(4) as entropy source. 2021-03-01 04:40:39 +00:00
rin 329efe10f2 Use dstemp(4) as entropy source. 2021-03-01 04:39:45 +00:00
thorpej 2110d4b72b - Add some additional compat strings from the DT bindings.
- Use device_compatible_entry::value to hold the device type, and generally
  tidy up device type selection.
2021-02-06 05:21:47 +00:00
thorpej 411dc0237f Add the standard compat string from the Device Tree bindings. 2021-01-30 17:38:57 +00:00
thorpej db426adf1c Add standard compat strings from the Device Tree bindings. 2021-01-30 17:38:27 +00:00
thorpej 387572e67e Add the standard compat string from the Device Tree bindings. 2021-01-30 17:37:25 +00:00
thorpej 501e085562 Add a proper compat string for this device, following the standard
conventions.
2021-01-30 01:23:08 +00:00
thorpej c08023f9bc If we're going to keep a reference on the "props" dictionary from
the i2c_attach_args, we should retain it.
2021-01-30 01:22:06 +00:00
thorpej 9da68ed61a No need to consult ia->ia_ncompat before calling iic_compatible_lookup(). 2021-01-28 14:57:43 +00:00
thorpej a9b41cc976 Use iic_compatible_lookup() in ssdfb_i2c_attach(). 2021-01-28 14:42:45 +00:00
thorpej d4daf0847c Use iic_compatible_lookup() in admtemp_setflags(). 2021-01-28 14:35:11 +00:00
thorpej 6e54367a22 Rename of_match_compat_data() to of_compatible_match(). Similarly,
rename of_search_compatible() to of_compatible_lookup().

Standardize on of_compatible_match() for driver matching, and adapt
all call sites.
2021-01-27 03:10:18 +00:00
thorpej 18f3098ca5 Use DEVICE_COMPAT_EOL. 2021-01-27 02:29:48 +00:00
thorpej 2649785eb3 Replace 2 uses of of_match_compatible(). Also use DEVICE_COMPAT_EOL. 2021-01-27 02:28:37 +00:00
thorpej 8dc2ddfa74 Now that the ACPI layer no longer does this for us, evaluate the _DSM
that returns the HID descriptor address at attach time.
2021-01-26 02:33:54 +00:00
thorpej 84eb440b90 Don't map ACPI _HID / _CID strings to "compatible" strings from the
Device Tree bindings.  Just pass those strings in the standard
most-specific-to-least-specific order to the drivers and let them
deal.
2021-01-26 01:23:08 +00:00
thorpej 51d15bc79d Back out unintended change in previous. 2021-01-26 01:15:39 +00:00
jmcneill 172e088e14 Add a device_t parameter to acpi_enter_i2c_devs. If non-NULL, all child
acpi_devnodes will be claimed by that device so we don't later try to
attach a duplicate device to that node at acpinodebus.
2021-01-26 00:19:52 +00:00
thorpej d588f10834 Since we're using designated initialisers for compat data, we should
use a completely empty initializer for the sentinel.
2021-01-25 13:30:20 +00:00
jmcneill 608e11c703 Add support for ACPI-based I2C mux attachment. 2021-01-25 12:18:18 +00:00
jmcneill 02b41e14ea Add "cookietype" to i2c attach args, so the consumer knows if ia_cookie
is either an OF phandle or an ACPI_HANDLE. Add NXP0002 compatible mapping
while here.
2021-01-25 12:15:32 +00:00
jmcneill 69a6f93785 NXP Layerscape LX2160A has an almost compatible controller, with a few
quirks:
 - IBCR bit 7 is "module disable" instead of "module enable".
 - Status bits in IBSR are W1C.
Add quirk flags for both.
2021-01-25 12:08:47 +00:00
jmcneill 6ca4166a8b remove part of previous that was committed by mistake 2021-01-24 19:38:49 +00:00
jmcneill 988bc6dbc1 trailing whitespace 2021-01-24 19:35:21 +00:00
jmcneill 9547a60780 Support non-FDT attachment. 2021-01-24 18:01:13 +00:00
rin c5759f0499 Use temperature sensors as rnd(9) sources. 2021-01-24 05:30:05 +00:00
thorpej 1f5ee02347 Change the device_compatible_match() function to only perform the match.
Introduce a device_compatible_lookup() function to return an entry based
on the same matching criteria (a'la of_search_compatible()).

Update iic_compatible_match() to reflect the above change, and introduce
iic_compatible_lookup().  This pattern is less awkward to use.
2021-01-18 15:28:21 +00:00
thorpej 39983299d2 Change the device_compatible_entry struct to have a union of
a scalar value (uintptr_t value) and a pointer value (const void *data),
rather than just "uintptr_t data".  This eliminates the need for drivers
to cast this value, and doesn't lose const'ness of pointers assigned
to the field.

Update all of the users of this field to use the correct set of
designated initialisers for each specific case.
2021-01-17 21:56:20 +00:00
thorpej 7246a94523 Use designated initializers and a consistent termination style in
compat_data[].
2021-01-17 21:42:35 +00:00
thorpej 614805fdc6 Rename tsl256x.c -> tsllux.c. No other changes are made by this commit. 2021-01-04 22:09:35 +00:00
thorpej 08733279a9 Tweak register bit names, in preparation for supporting younger siblings
of this chip.
2021-01-04 21:59:48 +00:00
thorpej cc55c171bf Add a driver for NXP PCA954x / PCA984x I2C switch / mux controllers. 2020-12-29 01:47:51 +00:00
thorpej 25cca672a0 - Use __BIT() macro to define I2C_F_* bits.
- Define an I2C_F_SPEED bitfield that can be used to specify an
  I2C bus speed:

  -> Standard Mode (100Kb/s)
  -> Fast Mode (400Kb/s)
  -> Fast Mode Plus (1Mb/s)
  -> High Speed (3.4Mb/s)

The speed values are treated as advisory; if a controller does not support
the requested speed mode, fallback to a lower one is allowed.

(Currently, all controllers simply use Standard Mode.)
2020-12-29 00:26:51 +00:00
thorpej 9f14734d43 Re-factor the "iicmux" driver to support other types of muxes that are
themselves i2c devices.
2020-12-28 20:29:57 +00:00
uwe 100c154117 G/c trailing whitespace. 2020-12-23 17:57:00 +00:00
thorpej 3524a0e97c Add direct-config support. 2020-12-23 17:10:37 +00:00
thorpej 21b71bc09d Change fdtbus_register_i2c_controller() to directly register the i2c_tag_t,
rather than the device and a set of functions (the only of which was to
return the i2c_tag_t anyway).  Previously, this assumed only a single
i2c controller node per device_t, which is not true with an i2c mux.
2020-12-23 16:02:11 +00:00
jdc 3ec70e08cf Handle pins that represent alerts.
split out common code for alert and indicator pins
  change the previously debug-only callout to work for alerts too
  split out common code for alerts in refresh and in callout
While here, remove redundant variable used for checking sysmon setup.
2020-12-23 07:06:26 +00:00
christos a5a15771d1 interupt -> interrupt 2020-12-16 19:49:04 +00:00
jdc 5b295983c9 Handle failing to acquire the iic bus.
Better handle errors when attaching sysmon sensors.
2020-12-10 17:02:51 +00:00
jdc 468b9986e5 Don't read from the chip when matching, fail the attach instead (requested
by jmcneill).  Reverts previous.
2020-12-06 10:09:36 +00:00
jdc 0a676d496a Return "match_result", not "1". Pointed out by jmcneill. 2020-12-05 15:02:29 +00:00
jdc 9b06680388 Make sure that we set sc->sc_sme to NULL in failure cases in order to avoid
calling sysmon_envsys_unregister() with an invalid struct when we detach.
2020-12-05 14:50:33 +00:00
jdc e79fb53ef9 When matching, try a read in case this is an optional device and isn't
actually present.
Make sure that we set sc->sc_sme to NULL in failure cases and when we
detach in order to avoid calling sysmon_envsys_unregister() with an
invalid struct.
2020-12-05 14:48:09 +00:00
skrll 777fa6409b Fix build and improve error handling 2020-11-26 12:53:03 +00:00
jdc 5f47dddb1a Detach led's and sysmon in our detach routine. 2020-10-31 14:39:31 +00:00
jdc 7140a529be Detach led's in our detach routine. 2020-10-31 14:38:54 +00:00
jdc 296377474d Add a driver for the PCF8574 I/O expander, used as a GPIO in some sparc64
hardware.
The driver currently handles pins configured as LED or INDICATOR and adds
them to the LED and sysmon_envsys subsystems, respectively.
2020-10-29 06:55:51 +00:00
jdc 45c58795d8 Handle the change in the sparc64 OFW patching, where we now encode the
GPIO pin type in the pin name (only LED types are currently handled).
2020-10-29 06:50:53 +00:00
jdc 561283d662 Add additional debugging output.
Track more chip state in the softc and check the chip state via a timer.
This allows us to easily observe changes caused by external events
(e.g. disk removal or PSU failure).
2020-10-27 20:13:21 +00:00
macallan e3eb5a785c more OF -> properties for sensor names, this should be the last one 2020-08-21 21:28:22 +00:00
macallan 811e47f2cc get sensore names from properties, remove OF code 2020-08-21 20:44:38 +00:00