Commit Graph

27 Commits

Author SHA1 Message Date
Pedro F. Giffuni
718cf2ccb9 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.
2017-11-27 14:52:40 +00:00
Warner Losh
6043585892 'private' isn't a PNP string field, so instead used the reserved '#'
name for this field (it might even be possible to just drop it
entirely, since it will be ignored either way).

Sponsored by: Netflix
2017-10-04 14:41:45 +00:00
Wojciech Macek
e5e94d2de9 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
2017-01-25 10:28:21 +00:00
Justin Hibbits
24f4202df8 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
2016-08-28 21:31:21 +00:00
Michal Meloun
895c8b1c39 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
2016-08-19 10:52:39 +00:00
Svatopluk Kraus
ad5244ece1 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
2016-06-05 16:20:12 +00:00
Ian Lepore
4cbedf8a36 Fix a typo in a comment. 2016-05-26 16:53:50 +00:00
Andrew Turner
1e43b18c4b 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
2016-05-16 09:31:44 +00:00
Adrian Chadd
91ef8da010 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
2016-02-09 03:35:40 +00:00
Warner Losh
31c9adb789 Create a simplebus PNP info wrapper.
Differential Review: https://reviews.freebsd.org/D4517
2015-12-18 05:29:22 +00:00
Michal Meloun
0b757c475b 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
2015-12-13 08:17:49 +00:00
Michal Meloun
821a61efa0 OFW: Move code for searching interrupt parent into separate function.
It can be used by interrupt controller drivers.

Approved by:	kib (mentor)
2015-12-02 14:21:16 +00:00
Warner Losh
bb39ff4c36 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
2015-06-20 04:48:48 +00:00
Oleksandr Tymoshenko
37c1967c5b Rename fdt_find_child to ofw_bus_find_child. There is nothing FDT-specific
in this function.

Suggested by: andrew@
2015-05-24 23:53:10 +00:00
Ruslan Bukin
a8c5ea04b4 Provide the number of interrupt resources added to the list
by using extra argument, so caller will know that.
2015-05-15 13:55:18 +00:00
Andrew Turner
8a56ddde27 Add the ofw_bus_subr.h change missed in r282770. 2015-05-11 15:47:55 +00:00
Zbigniew Bodek
4b3d916086 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
2015-01-13 00:00:09 +00:00
Ian Lepore
c47d4cde39 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
2014-09-25 15:02:33 +00:00
Nathan Whitehorn
e4be5a1636 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.
2014-02-02 16:41:54 +00:00
Nathan Whitehorn
95e3bfe889 Simplify the ofw_bus_lookup_imap() API slightly: make it allocate maskbuf
internally instead of requiring the caller to allocate it.
2013-12-17 15:11:24 +00:00
Ian Lepore
498fa7c1f9 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
2013-10-25 19:15:21 +00:00
Hiroki Sato
26ca49652b - 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
2012-08-18 11:25:07 +00:00
Nathan Whitehorn
eaef5f0af8 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
2010-06-18 14:06:27 +00:00
Rafal Jaworowski
8297758a22 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
2010-05-28 10:43:56 +00:00
Marius Strobl
481d6b549b Fix style. 2009-06-14 00:05:38 +00:00
Nathan Whitehorn
94b4a038a1 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
2008-12-15 15:31:10 +00:00
Marius Strobl
bba6f0a901 - 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
2005-11-22 16:37:45 +00:00