Commit graph

507 commits

Author SHA1 Message Date
Andriy Gapon a743e280ea rk_i2c: use the register read mode even if the read ends with IIC_M_NOSTOP
Tested with max44009(4).

MFC after:	2 weeks
2024-06-27 13:32:47 +03:00
Andriy Gapon 0deaf4be34 rk_i2c: emulate repeated start
rk_i2c_send_stop is modified so that it sends a stop condition, like it
always did, if there is no IIC_M_NOSTOP flag.
But if the flag is set then the function completely resets the control
register and sets the driver state to transfer completed.
Something like this was previously done for a write with IIC_M_NOSTOP.
Now it is done for a read with IIC_M_NOSTOP as well.

Linux code says that the hardware does not support the repeated start
condition and the documentation, indeed, does not mention it.
But according to the Linux driver clearing the control register and then
sending a start condition acts as if it were a repeated start.

While here, add braces around a single-line 'if' branch to balance it
with a multi-line 'else' branch.

Tested with max44009(4).

MFC after:	2 weeks
2024-06-27 13:32:15 +03:00
Mark Johnston 48f5a429c9 iicbus: Use device_set_descf()
No functional change intended.

MFC after:	1 week
2024-06-16 16:37:26 -04:00
Dmitry Salychev 645a228481
ds1307: Return error code instead of boolean
It's probably a copy-paste leftover from the other functions which
return a boolean value and generates annoying "CLOCK_SETTIME error 1"
from subr_rtc.c on Traverse Ten64 in verbose mode.

No functional changes intended.

MFC after:	3 days
2024-06-03 15:41:11 +02:00
John Baldwin 473c90ac04 uio: Use switch statements when handling UIO_READ vs UIO_WRITE
This is mostly to reduce the diff with CheriBSD which adds additional
constants to enum uio_rw, but also matches the normal style used for
uio_segflg.

Reviewed by:	kib, emaste
Obtained from:	CheriBSD
Differential Revision:	https://reviews.freebsd.org/D45142
2024-05-10 13:43:36 -07:00
Gordon Bergling fa3b320668 ds1307(4): Fix a typo in a source code comment
- s/slighly/slightly/

MFC after:	1 week
2024-04-20 14:14:21 +02:00
Ahmad Khalifa 67677a654a acpi_iicbus: Shift slave address
The address is expected to need shifting.
see https://uefi.org/specs/ACPI/6.5/13_System_Mgmt_Bus_Interface_Specification.html#smbus-slave-addresses

Reviewed by: imp, markj, Elliott Mitchell
Pull Request: https://github.com/freebsd/freebsd-src/pull/1125
2024-04-19 16:44:57 -06:00
Seth Hoffert 2cb0fce24d bpf: Make BPF interop consistent with if_loop
The pseudo_AF_HDRCMPLT check is already being done in if_loop and
just needed to be ported over to if_ic, if_wg, if_disc, if_gif,
if_gre, if_me, if_tuntap and ng_iface.  This is needed in order to
allow these interfaces to work properly with e.g., tcpreplay.

PR:		256587
Reviewed by:	markj
MFC after:	2 weeks
Pull Request:	https://github.com/freebsd/freebsd-src/pull/876
2024-04-19 14:48:37 -04:00
Josef 'Jeff' Sipek b724c8292d ds1307: use the correct Microchip part number in enum and device description
During a minor refactoring two years ago (part of 2486b446), the newly
created enum used the wrong part number - MCP7491x instead of MCP7941x.  The
device description string got the same transposition of digits.

This change swaps the digits back to what they should be.

Reviewed by:	emaste, tsoome, imp
Differential Revision: https://reviews.freebsd.org/D44436
2024-03-21 04:53:58 +02:00
Pierre-Luc Drouin 44847114bd vf_i2c: update I2C controller logic
Update the I2C controller logic to be more consistent with the
newer version of the controller reference manual.
This makes it work better on modern LS/LX platforms and avoids
unnecessary delays.  Also fixes a lock leak.

MFC after:	7 days
Tested by:	bz (LS1088a FDT), Pierre-Luc Drouin (Honeycomb, ACPI)
Differential Revision:	https://reviews.freebsd.org/D44021
2024-03-29 23:05:03 +00:00
Pierre-Luc Drouin 5ca8e32633 vf_i2c: split up and add ACPI attachments in addition to FDT
Move the code from the arm specific to the iicbus controller directory.
Split up between general logic and bus attachment code.
Add support for ACPI attachment in addition to FDT.

MFC after:	7 days
Tested by:	bz (LS1088a FDT), Pierre-Luc Drouin (Honeycomb, ACPI)
Based on:	D24917 by Val Packett (initial early version)
Differential Revision:	https://reviews.freebsd.org/D44020
2024-03-29 23:04:51 +00:00
Bjoern A. Zeeb c81df1c112 iicbus/mux/pca954x: add support for PCA9546 I2C Switch
Add support for the 4 channel I2C switch from NXP by adding a new
description struct and the list entries.  Compared to x=[2345] which
require code to support the INT, for this one no further changes are
needed.

Tested on:	WHLE-LS1088A using a SPF+
MFC after:	1 week
Reviewed by:	imp
Differential Revision: https://reviews.freebsd.org/D44009
2024-02-21 16:46:15 +00:00
Andriy Gapon a044cf60bd rk8xx_poweroff: add parentheses missed in 8b408fc6f2
Fixes:		8b408fc6f2
MFC after:	2 weeks
2024-02-18 18:29:00 +02:00
Andriy Gapon 8b408fc6f2 rk8xx_poweroff: enable power-cycling on support hardware
Previously, the function would return early if RB_POWERCYCLE was
specified without RB_POWEROFF.  Those flags are exclusive at the moment,
that is, they are never set together.

Søren Schmidt (sos) uses a similar but extended patch locally.

MFC after:	2 weeks
2024-02-18 16:04:29 +02:00
rilysh f61554272c sys/dev/iicbus/pmic/rockchip/rk8xx.c: remove an extra semicolon
Signed-off-by: rilysh <nightquick@proton.me>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/959
2024-02-02 18:35:00 -07:00
Andriy Gapon 34694f3da7 ds1307: restore hints-based configuration on FDT systems
Fall-through to non-FDT probe code if no matching device node is found.
While here, fix indentation of the switch statement.
Also, make the device description for the hints-based attachment the
same as for FDT attachment.

Fixes:	2486b446db ds1307: add support for the EPSON RX-8035SA I2C RTC
2024-01-28 12:45:57 +02:00
Emmanuel Vadot b2f0caf160 regulator: Move regulator code in dev/regulator
We've removed kernel option EXT_RESOURCES almost two years ago.
While it was ok to have some code under a common 'extres' subdirectory
at first, we now have a lot of consumer of it and we made it mandatory
so no need to have it under a cryptic name.

Reviewed by:	emaste, imp
Sponsored by:   Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D43194
2024-01-10 19:20:32 +01:00
Emmanuel Vadot 1f469a9fc4 hwreset: Move reset code in dev/hwreset
We've removed kernel option EXT_RESOURCES almost two years ago.
While it was ok to have some code under a common 'extres' subdirectory
at first, we now have a lot of consumer of it and we made it mandatory
so no need to have it under a cryptic name.

Reviewed by:	imp
Sponsored by:   Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D43192
2024-01-10 19:20:28 +01:00
Emmanuel Vadot be82b3a0bf clk: Move clock code in dev/clk
We've removed kernel option EXT_RESOURCES almost two years ago.
While it was ok to have some code under a common 'extres' subdirectory
at first, we now have a lot of consumer of it and we made it mandatory
so no need to have it under a cryptic name.

Reviewed by:	mhorne
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D43191
2024-01-10 19:20:26 +01:00
Emmanuel Vadot 3c2b2a28b9 iicbus: Move rockchip driver into the common directory
No need to keep it under sys/arm64/rockchip
It's easier to find which controller we support by looking under one directory.
While here remove the condition on SOC option, device rk_i2c is enough as all
Rockchip SoC that we support have this controller.

Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D43184
2024-01-10 19:20:10 +01:00
Alexander Motin 358453ce9b iichid(4): Switch taskqueue to "fast"
While "fast" taskqueue may be more expensive due to spinlock use,
when used mainly for timeout tasks it allows to avoid extra context
switches to and from callout thread, that is even more expensive.

MFC after:	1 month
2023-12-26 19:36:34 -05:00
Alexander Motin a8f80c0c16 iichid(4): Unify two taskqueue tasks
taskqueue_enqueue_timeout(0) is equivalent to taskqueue_enqueue(),
so no need to create a separate periodic_task and event_task to run
exactly the same handler.

MFC after:	1 month
2023-12-26 19:28:56 -05:00
Alexander Motin 68e457df02 iichid(4): Restore/increase sampling rate
My previous commit by reducing precision reduced the sampling rate
from 60Hz to 40Hz on idle system.  Return it back to 60-80Hz range,
that should be good for mouse smoothness on 60Hz displays.

MFC after:	1 months
2023-12-23 19:10:49 -05:00
Alexander Motin a74df3f96e iicbb: Fix pause_sbt() arguments order
It should make pause interval less strict.

While there, add cpu_spinwait() into a tight spin wait loop to burn
less power and let other SMT thread work more.

MFC after:	1 month
2023-12-23 18:58:51 -05:00
Alexander Motin 8c86b98124 iichid(4): Improve idle sampling hysteresis
In sampling mode some devices return same data indefinitely even if
there is nothing to report.  Previous idle hysteresis implementation
activated only when device returned no data, so some devices ended up
polled at fast rate all the time.  This new implementation compares
each new report with the previous, and, if they are identical, after
reaching threshold also drop sampling rate to slow.

On my Dell XPS 13 9310 with iichid(4) touchscreen and touchpad this
reduces idle power consumption by ~0.5W by reducing number of context
switches in the driver from ~4000 to ~700 per second when not touched.

MFC after:	1 month
2023-12-22 22:50:52 -05:00
Stephen J. Kiernan 682b069c5c iicbus: add compat32 support for I2C ioctls
Some of the I2C ioctl request structures contain pointers and need to
handle requests from 32-bit applications on 64-bit kernels.

Obtained from:	Juniper Networks, Inc.
Differential Revision:	https://reviews.freebsd.org/D42836
2023-11-30 20:33:46 -05:00
Warner Losh fdafd315ad sys: Automated cleanup of cdefs and other formatting
Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by:		Netflix
2023-11-26 22:24:00 -07:00
Emmanuel Vadot 1d6a6a5244 i2c: Add Microcrystal RV3032 RTC driver
This is a simple RTC driver for the rv3032 from Microcrystal.
Just the basic functionality is implemented (no timer, alarm etc ..).

Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D41995
2023-10-03 09:56:20 +02:00
Emmanuel Vadot 137b58e4d2 i2c: Add cadence iic driver
This IP is found in Xilinx SoC, it only been tested on ZynqMP (arm64)
so only enable it there for now.

Differential Revision:	https://reviews.freebsd.org/D41994
2023-10-03 09:56:20 +02:00
Emmanuel Vadot 125f5c5b48 iicbus: Move opencores i2c driver into controller subdirectory
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D41914
2023-10-03 09:56:20 +02:00
Emmanuel Vadot 7c569caa0a iicbus: Move i2c sensors drivers into new sensor subdirectory
No reason that they should live directly under iicbus

Sponsored by:   Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D41913
2023-10-03 09:56:20 +02:00
Emmanuel Vadot 06589d6e02 iicbus: Move ADC drivers into a new adc subfolder
No reason that they should live directly under iicbus

Sponsored by:   Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D41911
2023-10-03 09:56:19 +02:00
Emmanuel Vadot 22d7dd834b iicbus: Move adm1030 and adt746x to new pwm subdirectory
Those are (mainly) pwm controller so move it under a new subdirectory.

Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D41910
2023-10-03 09:56:19 +02:00
Emmanuel Vadot 062944cc42 iicbus: Move Silergy pmic/regulators under pmic/silergy subdirectory
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D41909
2023-10-03 09:56:19 +02:00
Emmanuel Vadot 2f16049c98 iicbus: Move remaining rtc driver into rtc subfolder
No reason that they should live directly under iicbus

Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D41908
2023-10-03 09:56:19 +02:00
Emmanuel Vadot 580d00f42f iicbus: Move twsi under a new controller subdirectory
The folder is a mess so start moving stuff into sub-directories.

Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D41907
2023-10-03 09:56:19 +02:00
Emmanuel Vadot 6694651138 iicbus: pmic: rk8xx: Fix logic in clock-output-names detection
Pointy hat to:	manu (probably)
2023-09-22 18:51:33 +02:00
Warner Losh 031beb4e23 sys: Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2023-08-16 11:54:58 -06:00
Warner Losh 685dc743dc sys: Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:36 -06:00
Warner Losh 95ee2897e9 sys: Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
2023-08-16 11:54:11 -06:00
Emmanuel Vadot ddefad7c4f arm64: rockchip: Tweak i2c, pmic and iodomain order
We need i2c first to set it to MIDDLE, then we need one of the pmics
so set them to LATE, only then we can attach iodomain which needs some
regulators exposed by the pmic so set it to LAST.

Sponsored by:	Beckhoff Automation GmbH & Co. KG
2023-08-08 15:58:26 +02:00
Vladimir Kondratyev 4b1712817e hid: Add child device parameter to HID methods
Some devices like Apple HID-over-SPI may contain more than one report
descriptors necessitating creation of multiple hidbus children.
Add indentificator of child devices to distinct them.
No functional changes intended.

Differential Revision:	https://reviews.freebsd.org/D41246
2023-08-03 19:10:50 +03:00
Warner Losh eebd9d5366 spdx: Simplify BSD-2-Clause AND BSD-2-Clause
After removing the -FreeBSD and -NetBSD, we're left with a nuber of
BSD-2-Clause AND BSD-2-Clause, so tidy that up.

Discussed with:		pfg
MFC After:		3 days
Sponsored by:		Netflix
2023-05-12 10:44:04 -06:00
Warner Losh b61a573019 spdx: The BSD-2-Clause-NetBSD identifier is obsolete, drop -NetBSD
The SPDX folks have obsoleted the BSD-2-Clause-NetBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with:		pfg
MFC After:		3 days
Sponsored by:		Netflix
2023-05-12 10:44:04 -06:00
Warner Losh 4d846d260e spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with:		pfg
MFC After:		3 days
Sponsored by:		Netflix
2023-05-12 10:44:03 -06:00
Zhenlei Huang deac4c7f07 iicbus(4): Use the existing CTLFLAG_RWTUN flag definition
Use it when possible, instead of separated flags.

No functional change intended.

Reviewed by:	hselasky, erj
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D39466
2023-04-12 12:20:38 +08:00
Justin Hibbits da247e0dac Mechanically convert ic(4) to IfAPI
Sponsored by:	Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D37851
2023-02-06 12:32:12 -05:00
Ganbold Tsagaankhuu 90737b632e Use BSD-2-Clause for the SPDX license id as -FreeBSD variant has been deprecated. 2023-01-06 08:15:44 +00:00
Søren Schmidt 571e5792f9 Change probe priority so order is correct. 2022-12-24 12:33:42 +00:00
Wojciech Macek 9476c1675c lm75: fix typo
s/sesnor/sensor/
2022-12-05 07:30:12 +01:00