aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/fdt/simplebus.c
Commit message (Collapse)AuthorAgeFilesLines
* sys: Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-231-1/+0
| | | | | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/ Similar commit in current: (cherry picked from commit 685dc743dc3b)
* spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh2023-07-251-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 (cherry picked from commit 4d846d260e2b9a3d4d0a701462568268cbfe7a5b)
* device_get_property: add a HANDLE caseBjoern A. Zeeb2023-01-181-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. Reviewed by: mw Differential Revision: https://reviews.freebsd.org/D36793 (cherry picked from commit 99e6980fcf5e12654c3e89b97b774de807d740a4)
* Extend device_get_property APIKornel Duleba2022-03-291-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 (cherry picked from commit b344de4d0d163cbd8bf88cb5d226c18fe96f488f)
* device: add device_get_property and device_has_propertyBartlomiej Grzesik2022-03-291-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 (cherry picked from commit 3f9a00e3b577dcca57e331842e0baf2dbdf9325f) acpi: Fix error code returned in acpi_bus_get_prop ACPI implementation of device_get_property would return "-1" when property was found, but it's type wasn't supported. This causes device_has_property to return false in that scenario, which arguably could be considered as incorrect. Fix that by returning "0" in that case. Reviewed by: bz, mw Tested by: mw MFC after: 2 weeks Obtained from: Semihalf Differential Revision: https://reviews.freebsd.org/D33103 (cherry picked from commit d9ed1dcc5c6894e376e6e4ef6f2554dd056baf4e)
* 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
* Teach nexus(4) about Open Firmware (e.g. FDT) on ARM and MIPS, retiringNathan Whitehorn2013-11-051-1/+1
| | | | | | | | | | | | | | | | | | | | fdtbus in most cases. This brings ARM and MIPS more in line with existing Open Firmware platforms like sparc64 and powerpc, as well as preventing double-enumeration of the OF tree on embedded PowerPC (first through nexus, then through fdtbus). This change is also designed to simplify resource management on FDT platforms by letting there exist a platform-defined root bus resource_activate() call instead of replying on fdtbus to do the right thing through fdt_bs_tag. The OFW_BUS_MAP_INTR() and OFW_BUS_CONFIG_INTR() kobj methods are also available to implement for similar purposes. Discussed on: -arm, -mips Tested by: zbb, brooks, imp, and others MFC after: 6 weeks Notes: svn path=/head/; revision=257702
* Remove OF_instance_to_package() hack for FDT and replace with use of theNathan Whitehorn2013-10-231-5/+3
| | | | | | | | generic OF_xref_phandle() API universally. Also replace some related explicit uses of fdt32_to_cpu() with OF_getencprop() calls. Notes: svn path=/head/; revision=256967
* MFP4: 223121 (FDT infrastructure portion)Brooks Davis2013-10-211-9/+117
| | | | | | | | | | | | | Implement support for interrupt-parent nodes in simplebus. The current implementation requires that device declarations have an interrupt-parent node and that it point to a device that has registered itself as a interrupt controller in fdt_ic_list_head and implements the fdt_ic interface. Sponsored by: DARPA/AFRL Notes: svn path=/head/; revision=256861
* Don't hesitate to ask parent to setup IRQ finally.Aleksandr Rybalko2013-03-181-3/+0
| | | | | | | Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=248485
* Allow simplebus to attach to another simplebus.Aleksandr Rybalko2013-03-181-0/+2
| | | | | | | Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=248482
* Hide "no default resources for" warning under bootverbose. It's ok to useAleksandr Rybalko2013-03-181-2/+3
| | | | | | | | | optional resources. Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=248481
* Allow simplebus to attach in less strict way, when "simple-bus" listed on notAleksandr Rybalko2013-03-181-2/+2
| | | | | | | | | | first position of compatible property, so simplebus driver can be generic driver for any bus listed as compatible with "simple-bus". Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=248480
* o Switch to use physical addresses in rman for FDT.Aleksandr Rybalko2013-03-181-3/+0
| | | | | | | | | o Remove vtophys used to translate virtual address to physical in case rman carry virtual. Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=248467
* Merging of projects/armv6, part 4Oleksandr Tymoshenko2012-08-151-10/+6
| | | | | | | | | | | | | | | | | | | | r233822: Remove useless and wrong piece of code in fdt_get_range() which i overwrites passed phandle_t node. Modify debug printf in fdt_reg_to_rl() to be consistent (that is, print start and end *virtual* addresses). r230560: Handle "ranges;" Make fdt_reg_to_rl() responsible for mapping the device memory, instead on just hoping that there's only one simplebus, and using fdt_immr_va as the base VA. r230315 Add a function to get the PA from range, instead of (ab)using fdt_immr_pa, and use it for the UART driver Notes: svn path=/head/; revision=239274
* Simplify simplebus_setup_intr and don't call MD code directly. We canMarcel Moolenaar2012-07-021-25/+20
| | | | | | | (and have to) trust our parent to handle interrupt configuration. Notes: svn path=/head/; revision=238044
* DEBUG is a kernel option. Don't define it here, as it breaks LINT.Marcel Moolenaar2011-12-301-3/+0
| | | | | | | | Since DEBUG was subsequently undefined, this is just debugging left- over. Notes: svn path=/head/; revision=228984
* Let simplebus(4) diagnostics be a bit more descriptive.Rafal Jaworowski2010-07-111-4/+7
| | | | Notes: svn path=/head/; revision=209904
* Import the common Flattened Device Tree infrastructure.Rafal Jaworowski2010-06-021-0/+333
o fdtbus(4) - the main abstract bus driver for all FDT-compliant systems. This is a direct replacement for the many incompatible bus drivers grouping integrated peripherals on embedded platforms (like obio(4), ocpbus(4) etc.) o simplebus(4) - bus driver representing ePAPR style 'simple-bus' node, which is an umbrella device for most of the integrated peripherals on a typical system-on-chip device. o Other components (common routines library, PCI node processing helper functions) Reviewed by: imp Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=208747