aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/ofw
Commit message (Collapse)AuthorAgeFilesLines
* OFW: Improve OFW_CPU.Michal Meloun2026-02-221-1/+10
| | | | | | | | Accept the assigned clock on the CPU node. Don't report a missing "clock-frequency" property if the CPU node has a "clocks" property. MFC after: 3 weeks
* bus_alloc_resource: Pass rid by value to BUS_ALLOC_RESOURCE DEVMETHODJohn Baldwin2025-12-092-5/+5
| | | | | | | | | The wrapper functions such as bus_alloc_resource_any() still support passing the rid by value or pointer, but the underlying implementation now passes by value. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D53402
* ofw: Add ofw_bus_is_machine_compat().Michal Meloun2025-12-032-0/+12
| | | | | | | | | We need a quick way to identify a given machine (SoC), mainly when implementing quirks for a given SoC. MFC after: 2 weeks Reviwed by: imp Differential Revision: https://reviews.freebsd.org/D53992
* dev/ofw: Teach ofw_cpu to find the pcpu on arm64Andrew Turner2025-11-181-2/+26
| | | | | | | Use the midr value to ensure we find the correct PCPU pointer on arm64. Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D53327
* dev/ofw: Register the ofw_cpu xrefAndrew Turner2025-10-271-0/+1
| | | | | | | | This allows it to be referenced by other devices. Reviewed by: jhibbits Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D53329
* dev/ofw: Move ofw_cpu earlierAndrew Turner2025-10-271-2/+4
| | | | | | | | | Move ofw_cpu to BUS_PASS_CPU + BUS_PASS_ORDER_MIDDLE so it can be used by other devices. Reviewed by: jhibbits Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D53328
* dev/ofw: Add interrupt-map supportAndrew Turner2025-07-211-6/+95
| | | | | | | | | | | | | Follow interrupt-map properties until either an interrupt controller or invalid node is found. In the former case return the translated details for the interrupt controller driver to decode. In the latter case return 0 as an error. Tested on the Arm DTS files that use interrupt-maps and with a userspace test. Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D51257
* machine/stdarg.h -> sys/stdarg.hBrooks Davis2025-06-113-6/+3
| | | | | | | | | | | | | Switch to using sys/stdarg.h for va_list type and va_* builtins. Make an attempt to insert the include in a sensible place. Where style(9) was followed this is easy, where it was ignored, aim for the first block of sys/*.h headers and don't get too fussy or try to fix other style bugs. Reviewed by: imp Exp-run by: antoine (PR 286274) Pull Request: https://github.com/freebsd/freebsd-src/pull/1595
* openfirm: Add OF_device_unregister_xrefEmannuel Vadot2025-04-032-0/+20
| | | | | | | | | | | | | When a device fails to attach, or a module is unloaded, we want to be able to unregister the xref as the device goes away. While the device_t may still be valid, it won't be providing whatever functionality the consumer that follows the xref wants it for and thus, we should not keep it discoverable. [Commit message re-worded by kevans@] Reviewed by: ian, imp Differential Revision: https://reviews.freebsd.org/D22945
* ofw_cpu: check for "disabled" status during probeMitchell Horne2025-01-101-9/+23
| | | | | | | | | | | | | | | | | | | | | | | | Some RISC-V CPUs contain a "monitor core" with limited functionality (no MMU). These cores appear in some device trees, but we don't run the kernel on them; in early CPU start-up code we skip them, and they have no impact on mp_ncpu. It seems the new trend is to mark these monitor cores with a 'status' property of 'disabled'. However, we still instantiate an ofw_cpu pseudo device for the disabled core. This is generally harmless, but there is an impact when attempting to attach the cpufreq_dt driver. It counts more OFW CPU devices (unit number) than logical CPUs (mp_ncpus), and therefore fails to attach for the last logical CPU. The solution is to check the status property in ofw_cpu_probe(), and fail if the core is marked "disabled". This is subject to the same exception already in ofw_cpu_early_foreach(); that is, if a disabled CPU has an 'enable-method' property, it can be used by the kernel. Reviewed by: andrew, jrtc27 MFC after: 1 month Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D48123
* ofw_cpu: collapse some #ifdef codeMitchell Horne2025-01-101-16/+27
| | | | | | | | | | | | | Mainly, to avoid repeating the list of architectures, #define HAS_CLK. Further, split the clk code into a helper function, which is a stub in the !HAS_CLK case. This aids in overall legibility. While here, add one separating whitespace, again for legibility. Reviewed by: jhb Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D48149
* ofw_cpu: fix __riscv preprocessor checkMitchell Horne2025-01-101-3/+3
| | | | | | | | | | | | | The canonical name is __riscv, not __riscv__. Newer compilers no longer emit the latter. This re-enables finding the nominal frequency from the CPU's clock. I checked, and there are no remaining mistakes like this in the tree. Reviewed by: jrtc27, imp, jhb Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D48122
* ofw: Fix inverted bcmp in ofw_bus_node_status_okayJessica Clarke2024-12-171-1/+1
| | | | | | | Otherwise this matches any two-character status except for ok. Fixes: e5e94d2de987 ("Expand OpenFirmware API with ofw_bus_node_status_okay method") MFC after: 1 week
* Replace calls to bus_generic_attach with bus_attach_childrenJohn Baldwin2024-12-064-5/+10
| | | | | Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D47675
* Replace calls to bus_generic_probe with bus_identify_childrenJohn Baldwin2024-12-062-2/+2
| | | | | Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D47674
* newbus: globally replace device_add_child(..., -1) with DEVICE_UNIT_ANYWarner Losh2024-07-252-2/+2
| | | | Sponsored by: Netflix
* Retire unused non-PCI_RES_BUS codeJessica Clarke2024-07-181-20/+0
| | | | | | | | All architectures define PCI_RES_BUS unconditionally now that only NEW_PCIB is supported, so we no longer need the legacy code. Reviewed by: jhb, andrew Differential Revision: https://reviews.freebsd.org/D32955
* Retire non-NEW_PCIB code and remove config optionJessica Clarke2024-07-181-10/+10
| | | | | | | | | | | All architectures enable NEW_PCIB in DEFAULTS (arm being the most recent to do so in 121be555997b (arm: Set NEW_PCIB in DEFAULTS rather than a subset of kernel configs")), so it's time we removed the legacy code that no longer sees much testing and has a significant maintenance burden. Reviewed by: jhb, andrew, emaste Differential Revision: https://reviews.freebsd.org/D32954
* ofw: convert boolean_t to boolMitchell Horne2024-06-265-12/+12
| | | | | | | | | | | Most of these already treat it as a proper bool, i.e. using true/false. Also fix-up callers of OF_install(). No functional change intended. Reviewed by: andrew, emaste Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D45733
* new-bus: Remove the 'rid' and 'type' arguments from BUS_RELEASE_RESOURCEJohn Baldwin2024-03-132-15/+9
| | | | | | | | | | The public bus_release_resource() API still accepts both forms, but the internal kobj method no longer passes the arguments. Implementations which need the rid or type now use rman_get_rid() or rman_get_type() to fetch the value from the allocated resource. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D44131
* new-bus: Remove the 'rid' and 'type' arguments from BUS_*ACTIVATE_RESOURCEJohn Baldwin2024-03-131-21/+12
| | | | | | | | | | The public bus_activate/deactivate_resource() API still accepts both forms, but the internal kobj methods no longer pass the arguments. Implementations which need the rid or type now use rman_get_rid() or rman_get_type() to fetch the value from the allocated resource. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D44130
* new-bus: Remove the 'type' argument from BUS_MAP/UNMAP_RESOURCEJohn Baldwin2024-03-131-10/+9
| | | | | | | | | | The public bus_map/unmap_resource() API still accepts both forms, but the internal kobj methods no longer pass the argument. Implementations which need the type now use rman_get_type() to fetch the value from the allocated resource. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D44129
* new-bus: Remove the 'type' argument from BUS_ADJUST_RESOURCEJohn Baldwin2024-03-131-6/+6
| | | | | | | | | | The public bus_adjust_resource() API still accepts both forms, but the internal kobj method no longer passes the argument. Implementations which need the type now use rman_get_type() to fetch the value from the allocated resource. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D44128
* ofw_pcib: Use bus_generic_rman_*John Baldwin2024-01-231-92/+123
| | | | | | | | | | | | | | | | - Implement bus_map/unmap_resource pulling bits from the previous ofw_pcib_activate/deactivate_resource. One difference here is that the bus_unmap_resource implementation uses bus_space_unmap instead of pmap_unmapdev as a complement to the existing use of bus_space_map. - Use bus_generic_rman_* in various routines for memory and I/O port resources. - Use pci_domain_* for PCI_RES_BUS in ofw_pcib_activate/deactivate_resource. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D43441
* clk: Move clock code in dev/clkEmmanuel Vadot2024-01-101-1/+1
| | | | | | | | | | | 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
* sys: Automated cleanup of cdefs and other formattingWarner Losh2023-11-278-8/+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 ancient SCCS tags.Warner Losh2023-11-272-4/+0
| | | | | | | | Remove ancient SCCS tags from the tree, automated scripting, with two minor fixup to keep things compiling. All the common forms in the tree were removed with a perl script. Sponsored by: Netflix
* 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-1613-25/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* sys: Remove $FreeBSD$: two-line .h patternWarner Losh2023-08-1611-22/+0
| | | | Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
* ofw_firmware: Return BUS_PROBE_GENERIC instead of 0Emmanuel Vadot2023-08-151-1/+6
| | | | | | | | | While here make it only probe if the node is directly under the root one. If it's not it's likely a device node named 'firmware' and not the firmware group we're interested in. Suggested by: jhb Sponsored by: Beckhoff Automation GmbH & Co. KG
* ofw_firmware: Only match if there is no compatibleEmmanuel Vadot2023-08-131-1/+4
| | | | | | | | | | If there is a compatible string it likely means that the firmware needs a dedicated driver (like on RPI*). PR: 273087 Tested-by: Mark Millard <marklmi26-fbsd@yahoo.com> Sponsored by: Beckhoff Automation GmbH & Co. KG Fixes: fdfd3a90b6ce ("ofw: Add a ofw_firmware driver")
* ofw: Add a ofw_firmware driverEmmanuel Vadot2023-08-081-0/+161
| | | | | | | | | | | | | | | | Some SoCs have an external firmware doing power management, clock and other stuffs. (Xilinx, ARM Juno etc ...) The way it is represent in the DTB is usually having a 'firmware' node under the root node and have some nodes under it with the correct compatible strings. The firmware node itself doesn't have any compatible strings. This driver is simple subclassed from simplebus and attaches at BUS_PASS_BUS + BUS_PASS_ORDER_MIDDLE so early drivers (like clock drivers) can still have a change to attach early. Reviewed by: andrew Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D37612
* ofw(4): Add my copyright and additional history for ofw_reg_to_paddr()Marius Strobl2023-07-261-0/+3
| | | | | | | The ofw_reg_to_paddr() in this file is the powerpc OF_decode_addr() formerly added in 812403402e0bc2165c03e37c6f657c7405f95c15. However, the latter function in turn was based on the sparc64 counterpart I previously added in 2b2250b149706f492dd615a518aa669e39b78d0a.
* ofw: remove redundant calls in ofwbus_attach()Christos Margiolis2023-05-251-6/+2
| | | | | | | | | | Since commit ecaecbc7d8bc212d8e854088106b3b21e631bb52, calling ofw_bus_gen_setup_devinfo() is redundant, as the call to device_set_ivars() now happens inside simplebus_add_device(). Reviewed by: markj Approved by: markj (mentor) Differential Revision: https://reviews.freebsd.org/D40271
* ofw_cpu: quiet secondary CPU devicesMitchell Horne2023-05-241-0/+5
| | | | | | | | | | | We already do plenty to announce the different CPUs in dmesg. Follow the ACPI CPU strategy of reporting the first CPU device, but quieting the rest for non-verbose boot. This cuts down slightly on dmesg output. Reviewed by: manu, jhb MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D40243
* ofw_cpu: whitespace cleanupMitchell Horne2023-05-241-21/+21
| | | | | | | Reviewed by: jhb, emaste MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D40242
* spdx: The BSD-2-Clause-NetBSD identifier is obsolete, drop -NetBSDWarner Losh2023-05-121-1/+1
| | | | | | | | | 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
* spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh2023-05-1212-12/+12
| | | | | | | | | 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
* ofw_cpu_early_foreach: Change callback to return bool instead of boolean_t.John Baldwin2023-05-041-1/+1
| | | | | Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D39926
* ofw: fix memory leak in ofwbus_attach()Christos Margiolis2023-04-101-0/+1
| | | | | | | | PR: 269509 Reported by: Jaroslaw Pelczar <jarek@jpelczar.com> Reviewed by: markj MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D38903
* ofwbus: only allow unit number zeroMitchell Horne2023-02-131-0/+5
| | | | | | | | | | | ofwbus has always been the root of attachment for OFW/FDT platforms. It may have simplebus children, but we expect only one instance of the ofwbus driver, added directly by nexus. We may as well ensure this remains the case. Reviewed by: jhb MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D38493
* ofwbus: remove arm64 ifdefsMitchell Horne2023-02-131-23/+2
| | | | | | | | | | | | | Rather than using the DEVICE_IDENTIFY method, let's have other ofwbus-using platforms add ofwbus0 explicitly in nexus, like arm64. This gives them the same flexibility, e.g. if riscv starts supporting ACPI, and cleans up the #ifdefs. We were doing this already on riscv, but adjust the 'order' parameters. Reviewed by: andrew, jhb MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D38492
* ofwbus: trim includesMitchell Horne2023-02-131-8/+0
| | | | | | | Nothing in the file today relies on these. Reviewed by: jhb Differential Revision: https://reviews.freebsd.org/D38491
* ofwbus: remove handling of resources from ofwbusElliott Mitchell2023-02-081-83/+9
| | | | | | | | | | | | | | | | | | | | The architecture nexus should handle allocation and release of memory and interrupts. This is to ensure that system-wide resources such as these are available to all devices, not just children of ofwbus0. On powerpc this moves the ownership of these resources up one level, from ofwbus0 to nexus0. Other architectures already have the required logic in their nexus implementation, so this eliminates the duplication of resources. An implementation of nexus_adjust_resource() is added for arm, arm64, and riscv. As noted by ian@ in the review, resource handling was the main bit of logic distinguishing ofwbus from simplebus. With some attention to detail, it should be possible to merge the two in the future. Co-authored by: mhorne MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D30554
* ofw: add BUS_GET_DEVICE_PATH interface to openfirm/fdt, somewhat incomplete.Takanori Watanabe2022-10-183-0/+18
| | | | | | | | | | | This add BUS_GET_DEVICE_PATH interface, which shows device tree of openfirm/fdt. In qemu-system-arm64 with "virt" machine with device-tree firmware, % devctl getpath OFW cpu0 Reviewed by: andrew Differential Revision: https://reviews.freebsd.org/D37031
* pmap_unmapdev/bios: Accept a pointer instead of a vm_offset_t.John Baldwin2022-09-221-1/+1
| | | | | | | | This matches the return type of pmap_mapdev/bios. Reviewed by: kib, markj Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D36548
* Adjust function definition in ofw to avoid clang 15 warningAndrew Turner2022-08-111-2/+2
| | | | | | | | | | | | | | | With clang 15, the following -Werror warning is produced: sys/dev/ofw/openfirm.c:826:9: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes] OF_enter() ^ void This is because OF_enter() and OF_exit are declared with a (void) argument list, but defined with an empty argument list. Make the definition match the declaration. Sponsored by: The FreeBSD Foundation
* Fix ofw pcib when it rman_init failsAndrew Turner2022-07-042-6/+23
| | | | | | | | | | | | rman_fini assumes rman_init has been called successfully. Clean up init faulure by only calling rman_fini when rman_init has succeeded. While here add ofw_pcib_fini that can be used by a sub-class to clean up. Reviewed by: bz, imp Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D35681
* ofw drivers: Remove unused devclass arguments to DRIVER_MODULE.John Baldwin2022-05-093-12/+4
|