History log of /freebsd-current/sys/dev/ofw/ofw_bus_subr.c
Revision Date Author Comments
# 685dc743 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

sys: Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 4d846d26 10-May-2023 Warner Losh <imp@FreeBSD.org>

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

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


# 7b5d62bb 18-Oct-2022 Takanori Watanabe <takawata@FreeBSD.org>

ofw: add BUS_GET_DEVICE_PATH interface to openfirm/fdt, somewhat incomplete.

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


# 0c0bfa0f 06-May-2022 Ruslan Bukin <br@FreeBSD.org>

Fix ofw_bus_iommu_map() since there is no limit on amount of maps
described in "iommu-map" DTS property.

Pointed out by: rpokala
Sponsored by: UKRI


# 0b6bacc7 06-May-2022 Ruslan Bukin <br@FreeBSD.org>

Add ofw_bus_iommu_map() that maps PCI requester ID to an IOMMU
specifier based on "iommu-map" DTS property.

Sponsored by: UKRI


# 3eae4e10 24-Jun-2021 Michal Meloun <mmel@FreeBSD.org>

Fix error value returned by ofw_bus_gen_get_node().

By definition ofw_bus_get_node() should consistently return -1 when there
is no associated OF node.

MFC after: 4 weeks
Discussed with: nwhitehorn
Analyzed in: https://reviews.freebsd.org/D30761


# c90902d3 22-Jun-2021 Warner Losh <imp@FreeBSD.org>

bus_child_pnpinfo: fix two stragglers

ddfc9c4c59e2 was missing changes to two files to complete the
bus_child_pnpinfo_str->bus_child_pnpinfo. This fixes the broken kernel
builds.

Sponsored by: Netflix


# f9874fbb 01-Sep-2020 Mateusz Guzik <mjg@FreeBSD.org>

ofw: clean up empty lines in .c and .h files


# 25f0326a 12-Jun-2018 Emmanuel Vadot <manu@FreeBSD.org>

simplebus pnp: Do not generate pnp info is the bus status is not okay

Generating the pnp info have the side effect to include all nodes even
if the status isn't "okay".
That means that loading the module will load but not attach as it checks
the status in the probe function.

On pine64 before :
root@pine64-lts:~ # devmatch -u
unattached on ofwbus pnpinfo name=memory
unattached on ofwbus pnpinfo name=chosen
unattached on ofwbus pnpinfo name=sound_spdif compat=simple-audio-card
unattached on ofwbus pnpinfo name=spdif-out compat=linux,spdif-dit
unattached on simplebus pnpinfo name=dma-controller@1c02000 compat=allwinner,sun50i-a64-dma
unattached on simplebus pnpinfo name=mmc@1c10000 compat=allwinner,sun50i-a64-mmc
unattached on simplebus pnpinfo name=usb@1c19000 compat=allwinner,sun8i-a33-musb
unattached on simplebus pnpinfo name=spdif@1c21000 compat=allwinner,sun50i-a64-spdif
unattached on simplebus pnpinfo name=i2s@1c22000 compat=allwinner,sun50i-a64-i2s
unattached on simplebus pnpinfo name=i2s@1c22400 compat=allwinner,sun50i-a64-i2s
unattached on simplebus pnpinfo name=serial@1c28400 compat=snps,dw-apb-uart
unattached on simplebus pnpinfo name=serial@1c28800 compat=snps,dw-apb-uart
unattached on simplebus pnpinfo name=serial@1c28c00 compat=snps,dw-apb-uart
unattached on simplebus pnpinfo name=serial@1c29000 compat=snps,dw-apb-uart
unattached on simplebus pnpinfo name=i2c@1c2ac00 compat=allwinner,sun6i-a31-i2c
unattached on simplebus pnpinfo name=i2c@1c2b000 compat=allwinner,sun6i-a31-i2c
unattached on simplebus pnpinfo name=i2c@1c2b400 compat=allwinner,sun6i-a31-i2c
unattached on ofwbus pnpinfo name=aliases
unattached on ofwbus pnpinfo name=symbols

All simplebus node are disabled

After :
root@pine64-lts:~ # devmatch -u
unattached on ofwbus pnpinfo name=memory
unattached on ofwbus pnpinfo name=chosen
unattached on ofwbus pnpinfo name=sound_spdif compat=simple-audio-card
unattached on ofwbus pnpinfo name=spdif-out compat=linux,spdif-dit
unattached on simplebus pnpinfo name=dma-controller@1c02000 compat=allwinner,sun50i-a64-dma
unattached on simplebus pnpinfo name=usb@1c19000 compat=allwinner,sun8i-a33-musb
unattached on ofwbus pnpinfo name=aliases
unattached on ofwbus pnpinfo name=symbols

Reviewed by: imp (with some objection)
Differential Revision: https://reviews.freebsd.org/D15770


# f7604b1b 09-Apr-2018 Oleksandr Tymoshenko <gonzo@FreeBSD.org>

Align OF_getencprop_alloc API with OF_getencprop and OF_getprop_alloc

Change OF_getencprop_alloc semantics to be combination of malloc and
OF_getencprop and return size of the property, not number of elements
allocated.

For the use cases where number of elements is preferred introduce
OF_getencprop_alloc_multi helper function that copies semantics
of OF_getencprop_alloc prior to this change.

This is to make OF_getencprop_alloc and OF_getencprop_alloc_multi
function signatures consistent with OF_getencprop_alloc and
OF_getencprop_alloc_multi.

Functionality-wise this patch is mostly rename of OF_getencprop_alloc
to OF_getencprop_alloc_multi except two calls in ofw_bus_setup_iinfo
where 1 was used as a block size.


# 217d17bc 08-Apr-2018 Oleksandr Tymoshenko <gonzo@FreeBSD.org>

Clean up OF_getprop_alloc API

OF_getprop_alloc takes element size argument and returns number of
elements in the property. There are valid use cases for such behavior
but mostly API consumers pass 1 as element size to get string
properties. What API users would expect from OF_getprop_alloc is to be
a combination of malloc + OF_getprop with the same semantic of return
value. This patch modifies API signature to match these expectations.

For the valid use cases with element size != 1 and to reduce
modification scope new OF_getprop_alloc_multi function has been
introduced that behaves the same way OF_getprop_alloc behaved prior to
this patch.

Reviewed by: ian, manu
Differential Revision: https://reviews.freebsd.org/D14850


# d310c9e0 03-Apr-2018 Marcin Wojtas <mw@FreeBSD.org>

Add api for creating resource list based on 'assigned-addresses'

According to device tree binding 'assigned-addresses' can refer to PCIE MMIO
register space. New function ofw_bus_assigned_addresses_to_rl is
provided to support it.

Submitted by: Rafal Kozik <rk@semihalf.com>
Obtained from: Semihalf
Sponsored by: Stormshield
Differential Revision: https://reviews.freebsd.org/D14750


# 8cc3cfa8 28-Jan-2018 Warner Losh <imp@FreeBSD.org>

Out of an abundance of caution, NUL out the first byte in the PNP
info.


# 151ba793 24-Dec-2017 Alexander Kabaev <kan@FreeBSD.org>

Do pass removing some write-only variables from the kernel.

This reduces noise when kernel is compiled by newer GCC versions,
such as one used by external toolchain ports.

Reviewed by: kib, andrew(sys/arm and sys/arm64), emaste(partial), erj(partial)
Reviewed by: jhb (sys/dev/pci/* sys/kern/vfs_aio.c and sys/kern/kern_synch.c)
Differential Revision: https://reviews.freebsd.org/D10385


# 718cf2cc 27-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

sys/dev: further adoption of SPDX licensing ID tags.

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.


# edf3dd3b 08-Aug-2017 Marcin Wojtas <mw@FreeBSD.org>

Enable using ofw_bus_find_compatible in early platform code

Before this patch function ofw_bus_find_compatible was using
memory allocations in order to find compatible node and the property's
length. This way there was always a suited buffer for property,
however this approach had also disadvantages - ofw_bus_find_compatible
couldn't be used when malloc is not available, e.g. during fdt fixup stage.

In order to remove the usage limitation of ofw_bus_find_compatible(),
this patch modifies the function to use ofw_bus_node_is_compatible()
(instead of the one without _int suffix), which uses a fixed
buffer on stack instead of dynamic allocations.

Submitted by: Patryk Duda <pdk@semihalf.com>
Reviewed by: nwhitehorn, cognet (mentor)
Approved by: cognet (mentor)
Obtained from: Semihalf
Differential Revision: https://reviews.freebsd.org/D11880


# 4d24901a 19-Feb-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

sys/dev: Replace zero with NULL for pointers.

Makes things easier to read, plus architectures may set NULL to something
different than zero.

Found with: devel/coccinelle
MFC after: 3 weeks


# e5e94d2d 25-Jan-2017 Wojciech Macek <wma@FreeBSD.org>

Expand OpenFirmware API with ofw_bus_node_status_okay
method

Method could be used before we can access device_t structure.
As per simple phandle_t handle we can access FDT to check
if specified node has been enabled.
It will be used in Marvell's common configuration code.

Submitted by: Konrad Adamczyk <ka@semihalf.com>
Obtained from: Semihalf
Sponsored by: Stormshield
Reviewed by: zbb, meloun-miracle-cz
Differential revision: https://reviews.freebsd.org/D9218


# 24f4202d 28-Aug-2016 Justin Hibbits <jhibbits@FreeBSD.org>

Check all compatible strings on uart devices in powerpc

Summary:
Some device trees put "fsl,ns16650" first in the compatible list. This causes
the probe code to choke, even though the device is compatible with ns16650, and
has it listed later in the tree.

Reviewed by: nwhitehorn
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D7676


# 895c8b1c 19-Aug-2016 Michal Meloun <mmel@FreeBSD.org>

INTRNG: Rework handling with resources. Partially revert r301453.
- 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


# ad5244ec 05-Jun-2016 Svatopluk Kraus <skra@FreeBSD.org>

INTRNG - change the way how an interrupt mapping data are provided
to the framework in OFW (FDT) case.

This is a follow-up to r301451.

Differential Revision: https://reviews.freebsd.org/D6634


# 1e43b18c 16-May-2016 Andrew Turner <andrew@FreeBSD.org>

Add a pcib interface for use by interrupt controllers that need to
translate the pci rid to a controller ID. The translation could be based
on the 'msi-map' OFW property, a similar ACPI option, or hard-coded for
hardware lacking the above options.

Reviewed by: wma
Obtained from: ABT Systems Ltd
Sponsored by: The FreeBSD Foundation


# 91ef8da0 08-Feb-2016 Adrian Chadd <adrian@FreeBSD.org>

Teach ofw_bus_parse_xref_list_alloc to be able to return the length of the parsed list.

Currently, there is no easy way to know in advance how many entries a list parsed by
ofw_bus_parse_xref_list_alloc() in sys/dev/ofw/ofw_bus_subr.c has.

This patch:

* teaches the existing function about handling idx == -1 and returning how big
the set is; then renames it as _internal;
* create a new function that asserts idx != -1, so the old API is maintained;
* add a new function that returns just the list length.

Submitted by: Stanislav Galabov <sgalabov@gmail.com>
Differential Revision: https://reviews.freebsd.org/D5043


# 086a6314 20-Jan-2016 Michal Meloun <mmel@FreeBSD.org>

OFW: Fix ofw_bus_string_list_to_array() function.
Originally committed version was unfinished and didn't work at all,
because I took it from the wrong WIP branch by mistake.

Approved by: kib (mentor)


# 9f4a7eae 02-Jan-2016 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Make using the #address-cells property on the interrupt parent in device
tree parsing opt-out rather than opt-in. All FDT-based systems as well as
PowerPC systems with real Open Firmware use the CHRP-derived binding that
includes it, which makes SPARC the odd man out here. Making it opt-out
avoids astonishment on new platform bring up.


# 122493cf 17-Dec-2015 Andrew Turner <andrew@FreeBSD.org>

Support the variant of the interrupt-map property where the parent bus has
the #address-cells property set. For this we need to read more data before
the parent interrupt description.

this is only enabled on arm64 for now as it's not quite compliant with the
ePAPR spec. We should use a default of 2 where the #address-cells property
is missing, however this will need further testing across architectures.

Obtained from: ABT Systems Ltd
Sponsored by: SoftIron Inc
Differential Revision: https://reviews.freebsd.org/D4518


# 0b757c47 13-Dec-2015 Michal Meloun <mmel@FreeBSD.org>

OFW: Add helper functions for parsing xref based lists.
By using this functions, we can parse a list of tuples, each of them holds
xref and variable number of values.
This kind of list is used in DT for clocks, gpios, resets ...

Discussed with: ian, nwhitehorn
Approved by: kib (mentor)
Differential Revision: https://reviews.freebsd.org/D4316


# 821a61ef 02-Dec-2015 Michal Meloun <mmel@FreeBSD.org>

OFW: Move code for searching interrupt parent into separate function.
It can be used by interrupt controller drivers.

Approved by: kib (mentor)


# 7339f782 24-Jul-2015 Oleksandr Tymoshenko <gonzo@FreeBSD.org>

OF_getencprop_alloc shouldn't be used to get string value. If string
length + 1 is not divisible by 4 this function returns NULL property
value. Otherwise - string with each 4 letters inverted


# 63e8633e 15-Jul-2015 Andrew Turner <andrew@FreeBSD.org>

Fix an infinite loop when a node doesn't have an interrupt-parent property.

Submitted by: Aleksey Kuleshov <rndfax@yandex.ru>
Differential Revision: https://reviews.freebsd.org/D3041


# f3856d8f 14-Jul-2015 Andrew Turner <andrew@FreeBSD.org>

Also accept "ok" to enable a device, some vendor device trees use this when
they mean "okay"


# bb39ff4c 19-Jun-2015 Warner Losh <imp@FreeBSD.org>

Add ofw_bus_find_child_by_phandle, a helper routine to find a device_t
child matchig a given phandle_t.

Differential Revision: https://reviews.freebsd.org/D2871


# 37c1967c 24-May-2015 Oleksandr Tymoshenko <gonzo@FreeBSD.org>

Rename fdt_find_child to ofw_bus_find_child. There is nothing FDT-specific
in this function.

Suggested by: andrew@


# a8c5ea04 15-May-2015 Ruslan Bukin <br@FreeBSD.org>

Provide the number of interrupt resources added to the list
by using extra argument, so caller will know that.


# a5b53ce4 13-May-2015 Andrew Turner <andrew@FreeBSD.org>

Use the correct node wen reading the compatible property.


# 72a638c7 11-May-2015 Andrew Turner <andrew@FreeBSD.org>

Add ofw_bus_find_compatible to find a compatible ofw node. This will be
used on ARM to help find the correct node to use to start secondary CPUs
as this happens before device enumeration.


# 4b3d9160 12-Jan-2015 Zbigniew Bodek <zbb@FreeBSD.org>

Introduce ofw_bus_reg_to_rl() to replace part of common bus code

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


# 08b96b9f 05-Jan-2015 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Restore use of ofw_bus_intr_to_rl() in the pseries vdevice driver after fixing
ofw_bus_intr_to_rl() to match the spec for unspecified interrupt-parent
properties.


# c47d4cde 25-Sep-2014 Ian Lepore <ian@FreeBSD.org>

Replace multiple nearly-identical copies of code to walk through an FDT
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


# 752ba930 01-Sep-2014 Ian Lepore <ian@FreeBSD.org>

Rename OF_xref_phandle() to OF_node_from_xref() and add a new function
that provides the inverse translation, OF_xref_from_node().

Discussed with: nwhitehorn


# e4be5a16 02-Feb-2014 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Add a set of helpers (ofw_bus_get_status() and ofw_bus_status_okay()) to
process "status" properties of OF nodes.

I've avoided adding new KOBJ methods here so that we don't have to modify
every ofw_bus in the tree. Since 100% of implementations of ofw_bus use
only ofw_bus_gen_*(), it might be worth garbage-collecting the other
methods as well.


# 95e3bfe8 17-Dec-2013 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Simplify the ofw_bus_lookup_imap() API slightly: make it allocate maskbuf
internally instead of requiring the caller to allocate it.


# cb6d9d6c 17-Dec-2013 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Configure interrupt sense based on device tree information. This extends
the OF interrupt map API to return sense information to the caller and
the PowerPC Open Firmware PCI base driver to use it to program the PIC.


# 498fa7c1 25-Oct-2013 Ian Lepore <ian@FreeBSD.org>

Add a helper routine to search for a compat string in a table that
associates compat strings with arbitrary values that mean something to
the driver. This is handy for drivers that support several variations
of similar hardware and need to know which one matched.

Reviewed by: imp, jmg, nwhitehorn


# d3a0a0f3 23-Oct-2013 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Make all Open Firmware internal interfaces endian-safe by using the new
OF_getencprop() API. This removes one explicit endianness conversion in
ofw_iicbus.c.


# 6064b6ac 20-Oct-2013 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Allow the OFW interrupt mapping code to work with PCI devices not enumerated
by Open Firmware, as in the case of FDT.


# c0888418 15-Sep-2013 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Add a kernel interface (OF_xref_phandle()) for systems where phandles
used as cross-references in the device tree and phandles as used by the
Open Firmware client interface are in different namespaces. This include
IBM pSeries hardware as well as FDT systems. FDT certainly abuses
ihandles for this purpose and should be modified to use this API
eventually. This changes no behavior on systems where FreeBSD already
worked.

Reviewed by: marius
Approved by: re (kib)
MFC after: 2 weeks


# 26ca4965 18-Aug-2012 Hiroki Sato <hrs@FreeBSD.org>

- Add OF_hasprop() and ofw_bus_has_prop(). These can be used to check
existence of the property.

- Fix ofw_bus_is_compatible{,_strict}() to prevent substring match in the
compatible string.

Reviewed by: raj


# 0d8d9eda 15-Mar-2012 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Make ofw_bus_get_node() consistently return -1 when there is no associated
OF node, instead of a random mixture of 0 and -1. Update all checks for 0
to check for -1 instead.

MFC after: 4 weeks


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# eaef5f0a 18-Jun-2010 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Provide for multiple, cascaded PICs on PowerPC systems, and extend the
OFW interrupt map interface to also return the device's interrupt parent.

MFC after: 8.1-RELEASE


# 8297758a 28-May-2010 Rafal Jaworowski <raj@FreeBSD.org>

Prepare and extend OFW layer for FDT support.

o Let OFW_INIT() and OF_init() return status value.

o Provide helper routines for 'compatible' property handling.

o Only compile OF and OFW code, which is relevant in FDT scenario.

o Other minor cosmetics

Reviewed by: imp
Sponsored by: The FreeBSD Foundation


# 481d6b54 13-Jun-2009 Marius Strobl <marius@FreeBSD.org>

Fix style.


# acb97117 03-Jan-2009 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Fix the OFW interrupt map parser to use its own idea of the number of interrupt
cells in the map, instead of using a value passed to it and then panicing if it
disagrees. This fixes interrupt map parsing for PCI bridges on some Apple
Uninorth PCI controllers.

Reported by: marcel
Tested on: G4 iBook, Sun Ultra 5


# 94b4a038 15-Dec-2008 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Adapt parts of the sparc64 Open Firmware bus enumeration code (in particular,
the code for parsing interrupt maps) to PowerPC and reflect their new MI
status by moving them to the shared dev/ofw directory.

This commit also modifies the OFW PCI enumeration procedure on PowerPC to
allow the bus to find non-firmware-enumerated devices that Apple likes to add,
and adds some useful Open Firmware properties (compat and name) to the pnpinfo
string of children on OFW SBus, EBus, PCI, and MacIO links. Because of the
change to PCI enumeration on PowerPC, X has started working again on PPC
machines with Grackle hostbridges.

Reviewed by: marius
Obtained from: sparc64


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# bba6f0a9 22-Nov-2005 Marius Strobl <marius@FreeBSD.org>

- Add a new method ofw_bus_default_get_devinfo() that allows to retrieve
a newly introduced struct ofw_bus_devinfo which can hold the OFW info
of a device recallable via the ofw_bus KOBJ interface. Introduce a set
of functions ofw_bus_gen_get_*() which use ofw_bus_default_get_devinfo()
to provide generic subroutines for implementing the rest of the ofw_bus
KOBJ interface in a bus driver.
This is inspired by bus_get_resource_list() and bus_generic_rl_*_resource()
and allows to reduce code duplication in bus drivers as they only have
to provide an ofw_bus_default_get_devinfo() implementation in order to
provide the ofw_bus KOBJ interface via ofw_bus_gen_get_*().
- While here add a comment to ofw_bus_if.m describing the intention of
the ofw_bus KOBJ interface.

Reviewed by: marcel