aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/ow
Commit message (Collapse)AuthorAgeFilesLines
* chore: replace {0, 0} with {DEV,KOBJ}METHOD_ENDEnji Cooper2026-02-253-3/+3
| | | | | | | | | | | | | | Both of the aforementioned macros have been present in FreeBSD for well over a decade: 2009 for `KOBJMETHOD_END`; 2011 for `DEVMETHOD_END`. Adapt all hardcoded references of `{0, 0}` with `DEVMETHOD_END` and `KOBJMETHOD_END` as appropriate. This helps ensure that future adaptations to drivers following patterns documented in driver(9) can be made more easily/without issue. MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D55414
* bus: Document special ranges of IVARsJohn Baldwin2026-02-171-1/+1
| | | | | | | | | | | | | Some IVAR indices are special in that they have global meaning across multiple buses where as other IVARs are always private to the local bus. Try to document this a bit and add constants for the various ranges to avoid future conflicts. This is a no-op, but IVAR indices are now generally defined as enums as that makes it easier to define them in terms of ranges. Reviewed by: imp, royger, andrew Differential Revision: https://reviews.freebsd.org/D54159
* Use bus_generic_detach instead of device_delete_children in detachJohn Baldwin2025-01-021-1/+1
| | | | | | | While here, check for errors from bus_generic_detach and move it to the start of detach if necessary. Differential Revision: https://reviews.freebsd.org/D47969
* bus_generic_detach: Delete children after detaching themJohn Baldwin2025-01-021-13/+0
| | | | | | | | | | | | | | | | | This provides better semantics as a standalone DEVMETHOD for device_attach as bus drivers should remove child devices they created as part of detach cleanup. The implementation calls bus_detach_children() first to permit child devices an opportunity to veto the detach operation. If that succeeds, device_delete_children() is used to delete the child devices. This requires fixing various drivers that were deleting devices explicitly (via a device_t pointer cached in the softc) after calling bus_generic_detach to stop doing that and just rely on bus_generic_detach to remove child devices. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D47959
* bus_delayed_attach_children: Switch return type to voidJohn Baldwin2024-12-061-1/+2
| | | | | | | This function never fails similar to bus_attach_children. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D47677
* Replace calls to bus_generic_attach with bus_attach_childrenJohn Baldwin2024-12-061-1/+2
| | | | | Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D47675
* ow: Use a bus_child_deleted method to free ivars for childrenJohn Baldwin2024-11-011-3/+7
| | | | | Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D47364
* newbus: globally replace device_add_child(..., -1) with DEVICE_UNIT_ANYWarner Losh2024-07-252-2/+2
| | | | Sponsored by: Netflix
* sys: Automated cleanup of cdefs and other formattingWarner Losh2023-11-272-2/+0
| | | | | | | | | | | | | | | | 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
* sys: Remove $FreeBSD$: one-line bare tagWarner Losh2023-08-161-2/+0
| | | | Remove /^\s*\$FreeBSD\$$\n/
* sys: Remove $FreeBSD$: one-line sh patternWarner Losh2023-08-162-2/+0
| | | | Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
* sys: Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-163-6/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* sys: Remove $FreeBSD$: two-line .h patternWarner Losh2023-08-163-6/+0
| | | | Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
* ow: Remove unused devclass arguments to DRIVER_MODULE.John Baldwin2022-05-093-10/+4
|
* newbus: Move from bus_child_{pnpinfo,location}_src to ↵Warner Losh2021-06-231-18/+4
| | | | | | | | | | | | | | | | | | | | | | bus_child_{pnpinfo,location} with sbuf Now that the upper layers all go through a layer to tie into these information functions that translates an sbuf into char * and len. The current interface suffers issues of what to do in cases of truncation, etc. Instead, migrate all these functions to using struct sbuf and these issues go away. The caller is also in charge of any memory allocation and/or expansion that's needed during this process. Create a bus_generic_child_{pnpinfo,location} and make it default. It just returns success. This is for those busses that have no information for these items. Migrate the now-empty routines to using this as appropriate. Document these new interfaces with man pages, and oversight from before. Reviewed by: jhb, bcr Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D29937
* Revert "Define PNP info after defining driver modules"Mark Johnston2021-01-231-4/+2
| | | | | | | | | | | | | | | This reverts commit aa37baf3d7cf51da92fd367476182802e71838ae. The reverted commit was motivated by a problem observed on stable/12, but it turns out that a better solution was committed in r348309 but not MFCed. So, revert this change since it is unnecessary and not really correct: it assumes that the order in which module metadata records is defined determines their order in the output linker set. While this seems to hold in my testing, it is not guaranteed. Reported by: cem Discussed with: imp MFC after: 3 days
* Define PNP info after defining driver modulesMark Johnston2021-01-211-2/+4
| | | | | | | | | | | | | | | | PNP info definitions currently have an unfortunate requirement in that they must follow the associated module definition in the module metadata linker set. Otherwise devmatch can segfault while processing the linker hints file since kldxref maintains the order in the linker set. A number of drivers violate this requirement. In some cases this can cause devmatch(8) to segfault when processing the linker hints file. Work around the problem for now simply by adjusting the drivers. Reviewed by: imp MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D28260
* ow: clean up empty lines in .c and .h filesMateusz Guzik2020-09-013-7/+3
| | | | Notes: svn path=/head/; revision=365183
* kernel: provide panicky version of __unreachableKyle Evans2020-05-131-1/+1
| | | | | | | | | | | | | | | | | | | | | __builtin_unreachable doesn't raise any compile-time warnings/errors on its own, so problems with its usage can't be easily detected. While it would be nice for this situation to change and compilers to at least add a warning for trivial cases where local state means the instruction can't be reached, this isn't the case at the moment and likely will not happen. This commit adds an __assert_unreachable, whose intent is incredibly clear: it asserts that this instruction is unreachable. On INVARIANTS builds, it's a panic(), and on non-INVARIANTS it expands to __unreachable(). Existing users of __unreachable() are converted to __assert_unreachable, to improve debuggability if this assumption is violated. Reviewed by: mjg Differential Revision: https://reviews.freebsd.org/D23793 Notes: svn path=/head/; revision=361011
* Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many)Pawel Biernacki2020-02-262-5/+7
| | | | | | | | | | | | | | | | | | | r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are still not MPSAFE (or already are but aren’t properly marked). Use it in preparation for a general review of all nodes. This is non-functional change that adds annotations to SYSCTL_NODE and SYSCTL_PROC nodes using one of the soon-to-be-required flags. Mark all obvious cases as MPSAFE. All entries that haven't been marked as MPSAFE before are by default marked as NEEDGIANT Approved by: kib (mentor, blanket) Commented by: kib, gallatin, melifaro Differential Revision: https://reviews.freebsd.org/D23718 Notes: svn path=/head/; revision=358333
* Update owc_gpiobus (one-wire over gpio) to the modern gpio_pin interface.Ian Lepore2019-12-171-105/+88
| | | | | | | | | | | | | | | | | | It used to be required that a device be a child of gpiobus(4) to manipulate gpio pins. That requirement didn't work well for FDT-based systems with many cross-hierarchy users of gpio, so a more modern framework was created that removed the old hierarchy requirement. These changes adapt the owc_gpiobus driver to use the newer gpio_pin_* functions to acquire, release, and manipulate gpio pins. This allows a single driver to work for both hinted-attachment and fdt-based systems, and removes the requirement that any one-wire fdt nodes must appear at the root of the devicetree. Differential Revision: https://reviews.freebsd.org/D22710 Notes: svn path=/head/; revision=355858
* Be consistent about checking return value from bus_delayed_attach_children.Warner Losh2019-12-131-3/+1
| | | | | | | | | | Most places checked, but a couple last minute changes didn't. Make them all use the return value. Noticed by: rpokala@ Notes: svn path=/head/; revision=355735
* Create new wrapper function: bus_delayed_attach_children()Warner Losh2019-12-131-1/+1
| | | | | | | | | | | | | Delay the attachment of children, when requested, until after interrutps are running. This is often needed to allow children to run transactions on i2c or spi busses. It's a common enough idiom that it will be useful to have its own wrapper. Reviewed by: ian Differential Revision: https://reviews.freebsd.org/D21465 Notes: svn path=/head/; revision=355727
* Do not attach children of owc_gpiobus until interrupts are working.Ian Lepore2019-12-101-1/+1
| | | | | | | | | | | | The children of the bus need to do IO on the bus to probe for hardware presence. Doing IO means timing the bus states using sbinuptime(), and that requires working timecounters, which are not initialized until after device attachment has completed. PR: 242526 Notes: svn path=/head/; revision=355598
* Regularize my copyright noticeWarner Losh2019-12-048-16/+8
| | | | | | | | | | | | o Remove All Rights Reserved from my notices o imp@FreeBSD.org everywhere o regularize punctiation, eliminate date ranges o Make sure that it's clear that I don't claim All Rights reserved by listing All Rights Reserved on same line as other copyright holders (but not me). Other such holders are also listed last where it's clear. Notes: svn path=/head/; revision=355394
* Remove redundant hw sysctl declaration. gcc CI complains, but clang doesn't.Warner Losh2019-10-301-1/+0
| | | | Notes: svn path=/head/; revision=354205
* ow(4): clean up stray white spaceAndriy Gapon2019-10-301-3/+3
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=354183
* ow(4): protocol timings can now be changed as sysctl-s / tunablesAndriy Gapon2019-10-301-22/+126
| | | | | | | | | | | | I limited potentially infinite timings by 960 us based on a footnote on page 38 of Maxim Integrated Application Note 937, Book of iButton Standards: "In order not to mask interrupt signalling by other devices on the 1–Wire bus, tRSTL + tR should always be less than 960 us." MFC after: 3 weeks Notes: svn path=/head/; revision=354181
* ow(4): increase regular mode recovery time, t_rec, to 15 usAndriy Gapon2019-10-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | Previously we used the minimal value of 1 us and it was really tight. Application Note 3829 has a table describing recommended t_rec values for various bus voltages, temperature conditions and numbers of slave devices. The new value decreases the maximum possible data rate from 16.3 Kbit/s to 13.3 Kbit/s, but it allows for up to four slaves on a 3.3V bus (under room temperature). References: - Maxim Integrated Application Note 3829 Determining the Recovery Time for Multiple-Slave 1-Wire(R) Networks - Maxim Integrated Application Note 937 Book of iButton Standards Discussed with: imp (D22108) MFC after: 3 weeks Notes: svn path=/head/; revision=354180
* owc_gpiobus: add missing space in r354077Andriy Gapon2019-10-251-1/+1
| | | | Notes: svn path=/head/; revision=354078
* owc_gpiobus_read_data: add recovery time to the read slotAndriy Gapon2019-10-251-1/+1
| | | | | | | | Reviewed by: imp MFC after: 2 weeks Notes: svn path=/head/; revision=354077
* owc_gpiobus_read_data: compare times in sbintime_t unitsAndriy Gapon2019-10-251-3/+3
| | | | | | | | | | | | | | | | | Previously the code used sbttous() before microseconds comparison in one place, sbttons() and nanoseconds in another, division by SBT_1US and microseconds in yet another. Now the code consistently uses multiplication by SBT_1US to convert microseconds to sbintime_t before comparing them with periods between calls to sbinuptime(). This is fast, this is precise enough (below 0.03%) and the periods defined by the protocol cannot overflow. Reviewed by: imp (D22108) MFC after: 2 weeks Notes: svn path=/head/; revision=354076
* owc_gpiobus_read_data: disable preemption earlierAndriy Gapon2019-10-251-1/+2
| | | | | | | | | | | Now this is done before starting the low pulse that has rather tight timing. Reviewed by: imp (D22108) MFC after: 2 weeks Notes: svn path=/head/; revision=354069
* ow_temp: better scopes for the lockAndriy Gapon2019-10-251-3/+3
| | | | | | | | | | | | | | The lock is used only for start / stop signaling. It is used only for 'flags' field and the related condition variable. This change is a follow-up to r354067, it was suggested by Warner in D22107. Suggested by: imp MFC after: 1 week Notes: svn path=/head/; revision=354068
* ow_temp: drop the lock around a call that can sleepAndriy Gapon2019-10-251-0/+2
| | | | | | | | | | | | This is similar to what is done around other calls that lead to own_command_wait() that can sleep. Reviewed by: imp MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D22107 Notes: svn path=/head/; revision=354067
* owc_gpiobus: small formatting cleanupAndriy Gapon2019-07-101-16/+15
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=349883
* fix up r349428, fix a typo made during "fdt" removalAndriy Gapon2019-06-261-1/+1
| | | | | | | | Reported by: ian MFC after: 11 days Notes: svn path=/head/; revision=349433
* owc_gpiobus: clean / fix up the driver module thingsAndriy Gapon2019-06-261-2/+4
| | | | | | | | | | | | | | | | "fdt" is removed from the driver module name as the driver does not require FDT and can work very well on hints based systems. A module dependency is added for gpiobus. Without that owc cannot resolve symbols in gpiobus if both are loaded as kernel modules. Finally, a driver module module version is added. Reviewed by: imp MFC after: 11 days Notes: svn path=/head/; revision=349428
* Extract eventfilter declarations to sys/_eventfilter.hConrad Meyer2019-05-201-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | This allows replacing "sys/eventfilter.h" includes with "sys/_eventfilter.h" in other header files (e.g., sys/{bus,conf,cpu}.h) and reduces header pollution substantially. EVENTHANDLER_DECLARE and EVENTHANDLER_LIST_DECLAREs were moved out of .c files into appropriate headers (e.g., sys/proc.h, powernv/opal.h). As a side effect of reduced header pollution, many .c files and headers no longer contain needed definitions. The remainder of the patch addresses adding appropriate includes to fix those files. LOCK_DEBUG and LOCK_FILE_LINE_ARG are moved to sys/_lock.h, as required by sys/mutex.h since r326106 (but silently protected by header pollution prior to this change). No functional change (intended). Of course, any out of tree modules that relied on header pollution for sys/eventhandler.h, sys/lock.h, or sys/mutex.h inclusion need to be fixed. __FreeBSD_version has been bumped. Notes: svn path=/head/; revision=347984
* Fix panic message when we can't create thread for one wire temperatureWarner Losh2018-12-201-1/+1
| | | | | | | reading. Notes: svn path=/head/; revision=342275
* [ofw] fix errneous checks for OF_finddevice(9) return valueOleksandr Tymoshenko2018-03-201-1/+1
| | | | | | | | | | | | | | | OF_finddevices returns ((phandle_t)-1) in case of failure. Some code in existing drivers checked return value to be equal to 0 or less/equal to 0 which is also wrong because phandle_t is unsigned type. Most of these checks were for negative cases that were never triggered so trhere was no impact on functionality. Reviewed by: nwhitehorn MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D14645 Notes: svn path=/head/; revision=331229
* Add inline functions to convert between sbintime_t and decimal time units.Ian Lepore2017-07-291-2/+2
| | | | | | | | | | | | | | Use them in some existing code that is vulnerable to roundoff errors. The existing constant SBT_1NS is a honeypot, luring unsuspecting folks into writing code such as long_timeout_ns*SBT_1NS to generate the argument for a sleep call. The actual value of 1ns in sbt units is ~4.3, leading to a large roundoff error giving a shorter sleep than expected when multiplying by the trucated value of 4 in SBT_1NS. (The evil honeypot aspect becomes clear after you waste a whole day figuring out why your sleeps return early.) Notes: svn path=/head/; revision=321686
* ow_temp: Update the temperature visible via the sysctl atomically, ratherGavin Atkinson2016-12-221-6/+6
| | | | | | | than using it as temporary calculation space. Notes: svn path=/head/; revision=310381
* ow_temp: Correct typo in commentGavin Atkinson2016-12-211-1/+1
| | | | Notes: svn path=/head/; revision=310379
* Don't repeat the the word 'the'Eitan Adler2016-05-171-1/+1
| | | | | | | | | | (one manual change to fix grammar) Confirmed With: db Approved by: secteam (not really, but this is a comment typo fix) Notes: svn path=/head/; revision=300050
* dev/ow: Tag an unreachable switch default.Pedro F. Giffuni2016-05-161-0/+2
| | | | | | | | | | | Coverity reports an uninitialized "dir" in case the switch defaults without hitting any case. Respect the original intent and quell the false positive with the relatively new __unreachable() builtin. CID: 1331566 Notes: svn path=/head/; revision=299973
* Cleanup unnecessary semicolons from the kernel.Pedro F. Giffuni2016-04-101-1/+1
| | | | | | | Found with devel/coccinelle. Notes: svn path=/head/; revision=297793
* Simply to appease gcc's warnings.Warner Losh2015-08-281-1/+1
| | | | Notes: svn path=/head/; revision=287239
* New 1-Wire bus implementation. 1-Wire controller is abstracted, thoughWarner Losh2015-08-279-0/+1836
only gpiobus configured via FDT is supported. Bus enumeration is supported. Devices are created for each device found. 1-Wire temperature controllers are supported, but other drivers could be written. Temperatures are polled and reported via a sysctl. Errors are reported via sysctl counters. Mis-wired bus detection is included for more trouble shooting. See ow(4), owc(4) and ow_temp(4) for details of what's supported and known issues. This has been tested on Raspberry Pi-B, Pi2 and Beagle Bone Black with up to 7 devices. Differential Revision: https://reviews.freebsd.org/D2956 Relnotes: yes MFC after: 2 weeks Reviewed by: loos@ (with many insightful comments) Notes: svn path=/head/; revision=287225