aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/ofw/ofwbus.c
Commit message (Collapse)AuthorAgeFilesLines
* sys: Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-231-2/+0
| | | | | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/ Similar commit in current: (cherry picked from commit 685dc743dc3b)
* ofwbus: only allow unit number zeroMitchell Horne2023-04-171-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 (cherry picked from commit afca197f5240ce2c2c7abfe5c9fbc50ba55f178b)
* ofwbus: remove arm64 ifdefsMitchell Horne2023-04-171-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 (cherry picked from commit 53d5e65eead0f713c5e256018d46edbec0a96c11)
* ofwbus: remove handling of resources from ofwbusElliott Mitchell2023-04-171-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 (cherry picked from commit f9bdaab95ec469738fbfc1f0edd3e8c744b7f71f)
* ofw: fix memory leak in ofwbus_attach()Christos Margiolis2023-04-171-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 (cherry picked from commit 38594ff9c0c9568b5082ba3273103904a6afd38e)
* INTRNG: Rework handling with resources. Partially revert r301453.Michal Meloun2016-08-191-56/+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/+59
| | | | | | | | | | | 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-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Fix bug in ofwbus_release_resource() for non-ofwbus descendantsZbigniew Bodek2016-02-181-4/+9
| | | | | | | | | | | | | | | | | Resource list for devices that are not ofwbus descendants, but got to ofwbus method via bus_generic_release_resource() call chain, cannot be found using BUS_GET_RESOURCE_LIST() used by ofwbus. In that case, changing device's resource list should be avoided (will not contain resource list prepared by ofw or simplebus). Pointy-hat to: zbb Reviewed by: wma Obtained from: Semihalf Sponsored by: Cavium Differential Revision: https://reviews.freebsd.org/D5304 Notes: svn path=/head/; revision=295754
* 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
* Move the point we attach the ofw driver on arm64 to nexus.c. This willAndrew Turner2015-05-051-0/+11
| | | | | | | allow us to have a single place to decide to use ofw or acpi. Notes: svn path=/head/; revision=282480
* Make simplebus a base class of ofwbus. This allows the elimination ofIan Lepore2015-03-271-230/+18
| | | | | | | | | | | | | | 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
* Introduce ofw_bus_reg_to_rl() to replace part of common bus codeZbigniew Bodek2015-01-131-31/+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
* Avoid panic in ofwbus caused by not released resource list entryZbigniew Bodek2014-11-071-1/+7
| | | | | | | | | | | | | | After resource allocation and release, resource list entry stays non-NULL. This causes panic in ofwbus_alloc_resource() on subsequent resource allocation. Clean appropriate list entry on release to avoid this. Obtained from: Semihalf Reviewed by: ian Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=274249
* Replace multiple nearly-identical copies of code to walk through an FDTIan Lepore2014-09-251-32/+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
* Handle various ways that interrupt config data can be malformed byIan Lepore2014-08-101-8/+22
| | | | | | | warning and assuming more or less reasonable values. Notes: svn path=/head/; revision=269770
* Use a separate variable for resource id, because 'i' may increment at aIan Lepore2014-08-101-5/+5
| | | | | | | rate greater than 1 on each iteration. Notes: svn path=/head/; revision=269769
* 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-1/+2
| | | | Notes: svn path=/head/; revision=269594
* OF_peer() in IEEE 1275 returns 0 if no peer exists, not -1.Nathan Whitehorn2014-05-111-1/+1
| | | | Notes: svn path=/head/; revision=265888
* Move Open Firmware device root on PowerPC, ARM, and MIPS systems toNathan Whitehorn2014-02-051-0/+527
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