aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/fdt/simplebus.c
Commit message (Collapse)AuthorAgeFilesLines
* simplebus: Stop accepting SYS_RES_IOPORT resourcesJohn Baldwin2025-01-291-3/+0
| | | | | | | | Child devices handling I/O port resources (such as PCI-e bridges) should map those to a memory resource and pass up a request for the translated memory resource. Differential Revision: https://reviews.freebsd.org/D48501
* 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
* Check for errors when detaching children first, not lastJohn Baldwin2024-11-051-1/+6
| | | | | | | | | | | | These detach routines in these drivers all ended with 'return (bus_generic_detach())' meaning that if any child device failed to detach, the parent driver was left in a mostly destroyed state, but still marked attached. Instead, bus drivers should detach child drivers first and return errors before destroying driver state in the parent. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D47387
* new-bus: Remove the 'rid' and 'type' arguments from BUS_RELEASE_RESOURCEJohn Baldwin2024-03-131-13/+1
| | | | | | | | | | 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-26/+2
| | | | | | | | | | 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-28/+2
| | | | | | | | | | 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-13/+1
| | | | | | | | | | 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
* simplebus: Implement bus_delete_resourceJohn Baldwin2024-02-161-0/+1
|
* simplebus: Map SYS_RES_IOPORT to SYS_RES_MEMORY later in alloc_resourceJohn Baldwin2024-02-161-3/+3
| | | | | | | | Specifically, the set/get_resource methods do not currently remap resource types, so remap the type in alloc_resource only after looking for a matching resource list entry. Fixes: 3cf553288b96 simplebus: Consistently map SYS_RES_IOPORT to SYS_RES_MEMORY
* simplebus: Consistently map SYS_RES_IOPORT to SYS_RES_MEMORYJohn Baldwin2024-01-231-7/+83
| | | | | Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D43442
* sys: Automated cleanup of cdefs and other formattingWarner Losh2023-11-271-1/+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 .c patternWarner Losh2023-08-161-1/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh2023-05-121-1/+1
| | | | | | | | | 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: add BUS_GET_DEVICE_PATH interface to openfirm/fdt, somewhat incomplete.Takanori Watanabe2022-10-181-0/+1
| | | | | | | | | | | 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
* device_get_property: add a HANDLE caseBjoern A. Zeeb2022-10-091-2/+17
| | | | | | | | | | This will resolve a reference and return the appropriate handle, a node on the simplebus or an ACPI_HANDLE for ACPI. For now we do not try to further abstract the return type. MFC after: 2 weeks Reviewed by: mw Differential Revision: https://reviews.freebsd.org/D36793
* fdt simple drivers: Remove unused devclass arguments to DRIVER_MODULE.John Baldwin2022-05-091-5/+3
|
* Extend device_get_property APIKornel Duleba2022-03-101-3/+46
| | | | | | | | | | | | | | | | | | | | | | | | | In order to support various types of data stored in device tree properties or ACPI _DSD packages, create a new enum so the caller can specify the expected type of a property they want to read, according to the binding. The bus logic will use that information to process the underlying data. For example in DT all integer properties are stored in BE format. In order to get constant results across different platforms we need to convert its endianness to match the host. Another example are ACPI_TYPE_INTEGER properties stored as uint64_t. Before this patch the ACPI logic would refuse to read them if the provided buffer was smaller than 8 bytes. Now this can be handled by using DEVICE_PROP_UINT32 type. Modify the existing consumers of this API to reflect the changes and update the man pages accordingly. Reviewed by: mw Obtained from: Semihalf MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D33457
* device: add device_get_property and device_has_propertyBartlomiej Grzesik2021-09-201-0/+16
| | | | | | | | | | | Generialize bus specific property accessors. Those functions allow driver code to access device specific information. Currently there is only support for FDT and ACPI buses. Reviewed by: manu, mw Sponsored by: Semihalf Differential revision: https://reviews.freebsd.org/D31597
* newbus: Move from bus_child_{pnpinfo,location}_src to ↵Warner Losh2021-06-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | 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
* Correctly handle nodes compatible with "syscon", "simple-bus".Michal Meloun2020-09-251-0/+10
| | | | | | | | | | | | | | | | Syscon can also have child nodes that share a registration file with it. To do this correctly, follow these steps: - subclass syscon from simplebus and expose it if the node is also "simple-bus" compatible. - block simplebus probe for this compatible string, so it's priority (bus pass) doesn't colide with syscon driver. While I'm in, also block "syscon", "simple-mfd" for the same reason. MFC after: 4 weeks Notes: svn path=/head/; revision=366156
* Make simplebus friendlier for subclassing.Michal Meloun2020-09-251-2/+27
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=366146
* Allow child classes of simplebus to call attach directlyAndrew Turner2020-08-031-3/+3
| | | | | | | | | | | | | | | | Reduce code duplication when a bus is subclassed from simplebus by allowing them to call simplebus_attach directly. This is useful when the child bus will just implement the same calls. As not all children will expect to have a ranges property, e.g. the Raspberry Pi firmware, allow this property to be missing. Reviewed by: manu Sponsored by: Innovate UK Differential Revision: https://reviews.freebsd.org/D25925 Notes: svn path=/head/; revision=363799
* fdt: Add support for simple-mfd busEmmanuel Vadot2018-12-121-8/+1
| | | | | | | | | | | | | | Quoting the binding Documentation : "These devices comprise a nexus for heterogeneous hardware blocks containing more than one non-unique yet varying hardware functionality." Reviewed by: loos Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D17751 Notes: svn path=/head/; revision=342008
* sys/dev: further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-271-0/+2
| | | | | | | | | | | | | | | Mainly focus on files that use BSD 2-Clause license, however the tool I was using misidentified many licenses so this was mostly a manual - error prone - task. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Notes: svn path=/head/; revision=326255
* "Buses" is the preferred plural of "bus"Conrad Meyer2017-01-151-1/+1
| | | | | | | | | | | | | | | | | | | | Replace archaic "busses" with modern form "buses." Intentionally excluded: * Old/random drivers I didn't recognize * Old hardware in general * Use of "busses" in code as identifiers No functional change. http://grammarist.com/spelling/buses-busses/ PR: 216099 Reported by: bltsrc at mail.ru Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=312234
* Revert r306473.Justin Hibbits2016-10-011-9/+0
| | | | | | | Some objections were noted, and it was purely a cosmetic change anyway. Notes: svn path=/head/; revision=306545
* Use the cell-index property as the unit number if available.Justin Hibbits2016-09-301-0/+9
| | | | | | | | | | | | | | | | Summary: NXP/Freescale, among others, includes an optional cell-index property on nodes to denote the SoC block number of the node. This can be useful if, for example, a node is disabled or nonexistent in the fdt, or the blocks are not organized in address-sorted order. For instance, on the P1022, DMA2 is located at CCSR offset 0xC000, while DMA1 is located at 0x21000. Reviewed By: jmcneill Differential Revision: https://reviews.freebsd.org/D8054 Notes: svn path=/head/; revision=306473
* INTRNG: Rework handling with resources. Partially revert r301453.Michal Meloun2016-08-191-2/+0
| | | | | | | | | | | | | | | | | | | | - Read interrupt properties at bus enumeration time and store it into global mapping table. - At bus_activate_resource() time, given mapping entry is resolved and connected to real interrupt source. A copy of mapping entry is attached to given resource. - At bus_setup_intr() time, mapping entry stored in resource is used for delivery of requested interrupt configuration. - For MSI/MSIX interrupts, mapping entry is created within pci_alloc_msi()/pci_alloc_msix() call. - For legacy PCI interrupts, mapping entry must be created within pcib_route_interrupt() by pcib driver itself. Reviewed by: nwhitehorn, andrew Differential Revision: https://reviews.freebsd.org/D7493 Notes: svn path=/head/; revision=304459
* INTRNG - change the way how an interrupt mapping data are providedSvatopluk Kraus2016-06-051-0/+2
| | | | | | | | | | | to the framework in OFW (FDT) case. This is a follow-up to r301451. Differential Revision: https://reviews.freebsd.org/D6634 Notes: svn path=/head/; revision=301453
* Use uintmax_t (typedef'd to rman_res_t type) for rman ranges.Justin Hibbits2016-03-181-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On some architectures, u_long isn't large enough for resource definitions. Particularly, powerpc and arm allow 36-bit (or larger) physical addresses, but type `long' is only 32-bit. This extends rman's resources to uintmax_t. With this change, any resource can feasibly be placed anywhere in physical memory (within the constraints of the driver). Why uintmax_t and not something machine dependent, or uint64_t? Though it's possible for uintmax_t to grow, it's highly unlikely it will become 128-bit on 32-bit architectures. 64-bit architectures should have plenty of RAM to absorb the increase on resource sizes if and when this occurs, and the number of resources on memory-constrained systems should be sufficiently small as to not pose a drastic overhead. That being said, uintmax_t was chosen for source clarity. If it's specified as uint64_t, all printf()-like calls would either need casts to uintmax_t, or be littered with PRI*64 macros. Casts to uintmax_t aren't horrible, but it would also bake into the API for resource_list_print_type() either a hidden assumption that entries get cast to uintmax_t for printing, or these calls would need the PRI*64 macros. Since source code is meant to be read more often than written, I chose the clearest path of simply using uintmax_t. Tested on a PowerPC p5020-based board, which places all device resources in 0xfxxxxxxxx, and has 8GB RAM. Regression tested on qemu-system-i386 Regression tested on qemu-system-mips (malta profile) Tested PAE and devinfo on virtualbox (live CD) Special thanks to bz for his testing on ARM. Reviewed By: bz, jhb (previous) Relnotes: Yes Sponsored by: Alex Perez/Inertial Computing Differential Revision: https://reviews.freebsd.org/D4544 Notes: svn path=/head/; revision=297000
* Introduce a RMAN_IS_DEFAULT_RANGE() macro, and use it.Justin Hibbits2016-02-201-1/+1
| | | | | | | | | | | | | | This simplifies checking for default resource range for bus_alloc_resource(), and improves readability. This is part of, and related to, the migration of rman_res_t from u_long to uintmax_t. Discussed with: jhb Suggested by: marcel Notes: svn path=/head/; revision=295832
* Convert rman to use rman_res_t instead of u_longJustin Hibbits2016-01-271-2/+2
| | | | | | | | | | | | | | | | | | | | | | | Summary: Migrate to using the semi-opaque type rman_res_t to specify rman resources. For now, this is still compatible with u_long. This is step one in migrating rman to use uintmax_t for resources instead of u_long. Going forward, this could feasibly be used to specify architecture-specific definitions of resource ranges, rather than baking a specific integer type into the API. This change has been broken out to facilitate MFC'ing drivers back to 10 without breaking ABI. Reviewed By: jhb Sponsored by: Alex Perez/Inertial Computing Differential Revision: https://reviews.freebsd.org/D5075 Notes: svn path=/head/; revision=294883
* SIMPLEBUS: Don't panic if child device doesn't have devinfo set.Michal Meloun2015-12-131-0/+6
| | | | | | | | | | | Strictly speaking, missing devinfo is error which can be caused by instantiating child using device_add_child() instead of BUS_ADD_CHILD(). However, we can tolerate it. Approved by: kib (mentor) Notes: svn path=/head/; revision=292159
* Provide the number of interrupt resources added to the listRuslan Bukin2015-05-151-1/+1
| | | | | | | by using extra argument, so caller will know that. Notes: svn path=/head/; revision=282972
* Make simplebus a base class of ofwbus. This allows the elimination ofIan Lepore2015-03-271-42/+101
| | | | | | | | | | | | | | duplicated code in the two classes, and also allows devices in FDT-based systems to declare simplebus as their parent and still work correctly when the FDT data describes the device at the root of the tree rather than as a child of a simplebus (which is common for interrupt, clock, and power controllers). Differential Revision: https://reviews.freebsd.org/D1990 Submitted by: Michal Meloun Notes: svn path=/head/; revision=280772
* Allow creating subclass of FDT simplebusJayachandran C.2015-02-271-25/+4
| | | | | | | | | | | Provide sys/dev/fdt/simplebus.h with the class declaration so that it is possible to subclass FDT simplebus. Differential Revision: https://reviews.freebsd.org/D1886 Reviewed by: nwhitehorn, imp Notes: svn path=/head/; revision=279368
* Introduce ofw_bus_reg_to_rl() to replace part of common bus codeZbigniew Bodek2015-01-131-30/+1
| | | | | | | | | | | | | | Instead of reusing the same reg parsing code, create one, common function that puts reg contents to the resource list. Address cells and size cells are passed rather than acquired here so that any bus can have different default values. Obtained from: Semihalf Reviewed by: andrew, ian, nwhitehorn Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=277098
* Fail to probe on simplebus nodes that lack a "ranges" property.Ian Lepore2014-10-191-1/+7
| | | | | | | | | | Increasingly, FDT data has the "simple-bus" compatible string on nodes that have children, but we wouldn't consider them to be busses. If the node lacks a ranges property then we will fail to attach successfully, so fail to probe as well. Notes: svn path=/head/; revision=273282
* Replace multiple nearly-identical copies of code to walk through an FDTIan Lepore2014-09-251-31/+2
| | | | | | | | | | | | | | | | | | | node's interrupts=<...> property creating resource list entries with a single common implementation. This change makes ofw_bus_intr_to_rl() the one true copy of that code and removes the copies of it from other places. This also adds handling of the interrupts-extended property, which allows specifying multiple interrupts for a node where each interrupt can have a separate interrupt-parent. The bindings for this state that the property cells contain an xref phandle to the interrupt parent followed by whatever interrupt info that parent normally expects. This leads to having a variable number of icells per interrupt in the property. For example you could have <&intc1 1 &intc2 26 9 0 &intc3 9 4>. Differential Revision: https://reviews.freebsd.org/D803 Notes: svn path=/head/; revision=272109
* Rename OF_xref_phandle() to OF_node_from_xref() and add a new functionIan Lepore2014-09-011-1/+1
| | | | | | | | | that provides the inverse translation, OF_xref_from_node(). Discussed with: nwhitehorn Notes: svn path=/head/; revision=270945
* Adjust ofwbus and simplebus to attach at BUS_PASS_ORDER_MIDDLE, so thatIan Lepore2014-08-051-1/+1
| | | | | | | a platform can attach some other bus first if necessary. Notes: svn path=/head/; revision=269597
* Set ofwbus and simplebus to attach during BUS_PASS_BUS.Ian Lepore2014-08-051-2/+4
| | | | Notes: svn path=/head/; revision=269594
* Better nomatch messages: include compat string. Also, flag devices asWarner Losh2014-02-121-4/+11
| | | | | | | | disabled in the successful probe message, but leave what that means to the actual driver (no semantic changes). Notes: svn path=/head/; revision=261791
* Move Open Firmware device root on PowerPC, ARM, and MIPS systems toNathan Whitehorn2014-02-051-1/+1
| | | | | | | | | | | a sub-node of nexus (ofwbus) rather than direct attach under nexus. This fixes FDT on x86 and will make coexistence with ACPI on ARM systems easier. SPARC is unchanged. Reviewed by: imp, ian Notes: svn path=/head/; revision=261513
* Follow r261352 by updating all drivers which are children of simplebusIan Lepore2014-02-021-0/+3
| | | | | | | | | | | | | | | | to check the status property in their probe routines. Simplebus used to only instantiate its children whose status="okay" but that was improper behavior, fixed in r261352. Now that it doesn't check anymore and probes all its children; the children all have to do the check because really only the children know how to properly interpret their status property strings. Right now all existing drivers only understand "okay" versus something- that's-not-okay, so they all use the new ofw_bus_status_okay() helper. Notes: svn path=/head/; revision=261410
* Be more robust with malformed interrupt config data. Instead of crashingIan Lepore2014-02-021-5/+17
| | | | | | | | or going into a near-infinite loop, warn and make potentially-reasonable assumptions. Notes: svn path=/head/; revision=261405
* Allow nesting of simplebuses.Nathan Whitehorn2014-02-021-0/+1
| | | | Notes: svn path=/head/; revision=261397
* Provide a simpler and more standards-compliant simplebus implementation toNathan Whitehorn2014-02-011-265/+252
| | | | | | | | | | get the Routerboard 800 up and running with the vendor device tree. This does not implement some BERI-specific features (which hopefully won't be necessary soon), so move the old code to mips/beri, with a higher attach priority when built, until MIPS interrupt domain support is rearranged. Notes: svn path=/head/; revision=261352
* Retire machine/fdt.h as a header used by MI code, as its function is nowNathan Whitehorn2014-01-051-2/+0
| | | | | | | | | | | | | | | | | | obsolete. This involves the following pieces: - Remove it entirely on PowerPC, where it is not used by MD code either - Remove all references to machine/fdt.h in non-architecture-specific code (aside from uart_cpu_fdt.c, shared by ARM and MIPS, and so is somewhat non-arch-specific). - Fix code relying on header pollution from machine/fdt.h includes - Legacy fdtbus.c (still used on x86 FDT systems) now passes resource requests to its parent (nexus). This allows x86 FDT devices to allocate both memory and IO requests and removes the last notionally MI use of fdtbus_bs_tag. - On those architectures that retain a machine/fdt.h, unused bits like FDT_MAP_IRQ and FDT_INTR_MAX have been removed. Notes: svn path=/head/; revision=260327
* Reimplement fdt_intr_to_rl() in terms of OFW_BUS_MAP_INTR() andNathan Whitehorn2014-01-041-1/+1
| | | | | | | | OFW_BUS_CONFIG_INTR(). This function is only used by simplebus, so will likely be moved there in the future. Notes: svn path=/head/; revision=260282