Commit Graph

170 Commits

Author SHA1 Message Date
Warner Losh
031beb4e23 sys: Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2023-08-16 11:54:58 -06:00
Warner Losh
685dc743dc sys: Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:36 -06:00
Warner Losh
95ee2897e9 sys: Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
2023-08-16 11:54:11 -06:00
Warner Losh
4d846d260e 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
2023-05-12 10:44:03 -06:00
John Baldwin
afdb42987c ofw_cpu_early_foreach: Change callback to return bool instead of boolean_t.
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D39926
2023-05-04 12:33:39 -07:00
Elliott Mitchell
21cc0918c7 sys: Nuke double-semicolons
A distinct number of double-semicolons have ended up in FreeBSD.  Take a
pass at getting rid of many of these harmless typos.

Reviewed by: emaste, rrs
Pull Request: https://github.com/freebsd/freebsd-src/pull/609
Differential Revision: https://reviews.freebsd.org/D31716
2022-11-02 09:34:20 -06:00
Takanori Watanabe
7b5d62bb73 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
2022-10-18 16:55:47 +09:00
Bjoern A. Zeeb
99e6980fcf device_get_property: add a HANDLE case
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
2022-10-09 21:51:25 +00:00
John Baldwin
0a73fdb903 fdt simple drivers: Remove unused devclass arguments to DRIVER_MODULE. 2022-05-09 14:26:44 -07:00
Kornel Duleba
b344de4d0d Extend device_get_property API
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
2022-03-10 12:11:32 +01:00
Bartlomiej Grzesik
3f9a00e3b5 device: add device_get_property and device_has_property
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
2021-09-20 17:17:57 +02:00
Ed Maste
9feff969a0 Remove "All Rights Reserved" from FreeBSD Foundation sys/ copyrights
These ones were unambiguous cases where the Foundation was the only
listed copyright holder (in the associated license block).

Sponsored by:	The FreeBSD Foundation
2021-08-08 10:42:24 -04:00
Warner Losh
ddfc9c4c59 newbus: Move from bus_child_{pnpinfo,location}_src to 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
2021-06-22 20:52:06 -06:00
Michal Meloun
f97f57b518 simple_mfd: switch to controllable locking for syscon provider.
MFC after	3 weeks
2021-03-04 16:12:39 +01:00
Michal Meloun
8dc348a479 Correctly handle nodes compatible with "syscon", "simple-bus".
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
2020-09-25 13:52:31 +00:00
Michal Meloun
b95a8021ec Make simplebus friendlier for subclassing.
MFC after:	1 week
2020-09-25 09:56:50 +00:00
Andrew Turner
bc9b178cd0 Allow child classes of simplebus to call attach directly
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
2020-08-03 16:26:10 +00:00
Pawel Biernacki
7029da5c36 Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many)
r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are
still not MPSAFE (or already are but aren’t properly marked).
Use it in preparation for a general review of all nodes.

This is non-functional change that adds annotations to SYSCTL_NODE and
SYSCTL_PROC nodes using one of the soon-to-be-required flags.

Mark all obvious cases as MPSAFE.  All entries that haven't been marked
as MPSAFE before are by default marked as NEEDGIANT

Approved by:	kib (mentor, blanket)
Commented by:	kib, gallatin, melifaro
Differential Revision:	https://reviews.freebsd.org/D23718
2020-02-26 14:26:36 +00:00
Emmanuel Vadot
94292d7e95 fdt_pinctrl: Add new methods for gpios
Most of the gpio controller cannot configure or get the configuration
of the pin muxing as it's usually handled in the pinctrl driver.
But they can know what is the pinmuxing driver either because they are
child of it or via the gpio-range property.
Add some new methods to fdt_pinctrl that a pin controller can implement.
Some methods are :
fdt_pinctrl_is_gpio: Use to know if the pin in the gpio mode
fdt_pinctrl_set_flags: Set the flags of the pin (pullup/pulldown etc ...)
fdt_pinctrl_get_flags: Get the flags of the pin (pullup/pulldown etc ...)

The defaults method returns EOPNOTSUPP.

Reviewed by:	ian, bcr (manpages)
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D23093
2020-01-16 21:19:27 +00:00
Kyle Evans
0ddc94d67b fdt_slicer: bump to SI_ORDER_THIRD following r347183
r347183 bumped GEOM classes to SI_ORDER_SECOND to resolve a race between
them and the initialization of devsoftc.mtx in devinit, but missed this
dependency on g_flashmap that may now lose the race against GEOM
classes/g_init.

There's a great comment that describes the situation that has also been
updated with the new ordering of GEOM classes.

Reported by:	bdragon
MFC after:	4 days
2019-09-29 03:12:35 +00:00
Michal Meloun
76eeda8557 Fix bug introduced by r351184.
We should check the returned handle, not the pointer to it.

Noticed by:	ian
X-MFC with:	r351184
MFC after:	1 week
2019-08-18 15:37:19 +00:00
Michal Meloun
7f8c4c78f5 Add method for getting of syscon handle from parent device.
If simple multifuction device also provides syscon interface, its
childern should be able to consume it. Due to this:
- declare coresponding method in syscon interface
- implement it in simple multifunction device driver

MFC after:	1 week
2019-08-18 08:08:56 +00:00
Emmanuel Vadot
b52d0dc469 Revert r351129
the point of syscon node is to avoid multiple device driver reading/writing
to the same area.

Reported by:	ian
2019-08-17 19:05:11 +00:00
Emmanuel Vadot
be6d7fc657 fdt: simple-mfd: Set the syscon memory to SHAREABLE
Since syscon is usually used with another compatible string (and so
another driver), this driver might want to map the memory too.

MFC after:	1 week
2019-08-16 17:08:06 +00:00
Ganbold Tsagaankhuu
73155b4327 Extend simple_mfd driver to expose a syscon interface if
that node is also compatible with syscon. For instance,
Rockchip RK3399's GRF (General Register Files) is compatible
with simple-mfd as well as syscon and has devices like
usb2-phy, emmc-phy and pcie-phy etc. under it.

Reviewed by:	manu
2019-07-02 08:47:18 +00:00
Ed Maste
5eb264119e cpsw: use phy-handle in FDT to find PHY address
In r337703 DTS files were updated to Linux 4.18, including Linux commit
4d8b032d3c03f4e9788a18bbb51b10e6c9e8a56b which removed the `phy_id`
property from am335x-bone-common (as the property was deprecated).

Use `phy-handle` via fdt_get_phyaddr, keeping the existing code as a
fallback for old DTBs.

PR:		236624
Submitted by:	manu, Gerald Aryeetey <aryeeteygerald_rogers.com>
Reported by:	Gerald Aryeetey
Reviewed by:	manu
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D19814
2019-04-03 21:01:53 +00:00
Justin Hibbits
e5657ef4cf fdt: Explicitly mark fdt_slicer as dependent on geom_flashmap
Without this dependency relationship, the linker doesn't find the
flash_register_slicer() function, so kldload fails to load fdt_slicer.ko.

Discussed with:	ian@
2019-03-17 04:33:17 +00:00
Ian Lepore
a6bcabcd06 Add support to fdt_slicer for the new style partition data documented in
devicetree/bindings/mtd/partition.txt.

In the old style, all the children of the device node which did not have a
compatible property were the partitions.  In the new style, there is a child
node of the device which has a compatible string of "fixed-partitions", and
its children are the individual partitions.

Also, support the read-only property by setting the corresponding slice flag.
2019-02-27 04:58:18 +00:00
Ian Lepore
85f55a2a97 Child nodes with a compatible property are not slices, according to the
devicetree/bindings/mtd/partitions.txt document, so just ignore them.
2019-02-27 04:19:29 +00:00
Ian Lepore
db58d718e9 Rename some functions and variables to have shorter names, which allows
unwrapping multiple lines of code.  Also, convert some short multiline
comments into single-line comments.  Change old-school FALSE to false.

All in all, no functional changes, it's just more compact and readable.
2019-02-27 04:16:32 +00:00
Ian Lepore
4e46217874 Make it possible to load fdt_slicer as a module (unloading works too fwiw). 2019-02-26 22:34:29 +00:00
Emmanuel Vadot
2091650b73 fdt: Add support for simple-mfd bus
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
2018-12-12 21:56:45 +00:00
Emmanuel Vadot
413d07ea3e fdt_pinctrl: Add some TSLOG annotations
While we see the time spent in the pin controller attach via the hooks in
DEVICE_ATTACH, it is useful to see the time spent configuring the pins.
2018-07-19 11:41:53 +00:00
Andrew Turner
c0fd148b5d Increase the number of fdt memory regions we support to 16. Some SoCs have
many excluded regions causing a buffer overflow in the early boot code if
this value is too small.

Obtained from:	ABT Systems Ltd
Sponsored by:	Turing Robotic Industries
2018-05-29 17:44:40 +00:00
Andrew Turner
1442afc1c7 Handle reserved memory with the no-map property.
We shouldn't be mapping this memory, so we need to find it so it
can be excluded from the phys_avail map.

Reviewed by:	manu
Obtained from:	ABT Systems Ltd
Sponsored by:	Turing Robotic Industries
Differential Revision:	https://reviews.freebsd.org/D15518
2018-05-22 16:03:41 +00:00
Oleksandr Tymoshenko
f7604b1b27 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.
2018-04-09 22:06:16 +00:00
Oleksandr Tymoshenko
217d17bcd3 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
2018-04-08 22:59:34 +00:00
Andrew Turner
9d9889b5eb Replace calls to fdt_is_compatible with ofw_bus_node_is_compatible. These
are almost identical so there is no need to keep the former around.

Sponsored by:	DARPA, AFRL
2018-04-08 22:07:06 +00:00
Andrew Turner
9f56e37dbe Revert r332277, it contained an unintended extra change 2018-04-08 15:21:12 +00:00
Andrew Turner
ae6874eb3f Replace calls to fdt_is_compatible with ofw_bus_node_is_compatible. These
are almost identical so there is no need to keep the former around.

Sponsored by:	DARPA, AFRL
2018-04-08 15:12:36 +00:00
Andrew Turner
626a198305 Move fdt_is_type to be a Marvell specific function. It's not used by any
other SoCs.

Sponsored by:	DARPA, AFRL
2018-04-08 12:20:06 +00:00
Andrew Turner
9e4fa9eb4a Remove fdt_pm_is_enabled as it's Marvell specific. Replace the only call to
it with a call to the helper function fdt_pm_is_enabled would call.

Sponsored by:	DARPA, AFRL
2018-04-04 13:37:59 +00:00
Andrew Turner
12295c211a Remove fdt_is_enabled, fdt_reg_to_rl, and fdt_get_unit. These are not used
by anything in the tree.

Sponsored by:	DARPA, AFRL
2018-04-03 13:30:40 +00:00
Andrew Turner
7bc28467ef Switch users of fdt_is_enabled to use ofw_bus_node_status_okay. These are
equivalent, so to prepare to remove the former move users to call the
latter.

Sponsored by:	DARPA, AFRL
2018-04-03 11:01:50 +00:00
Oleksandr Tymoshenko
108117cc22 [ofw] fix errneous checks for OF_finddevice(9) return value
OF_finddevices returns ((phandle_t)-1) in case of failure. Some code
in existing drivers checked return value to be equal to 0 or
less/equal to 0 which is also wrong because phandle_t is unsigned
type. Most of these checks were for negative cases that were never
triggered so trhere was no impact on functionality.

Reviewed by:	nwhitehorn
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D14645
2018-03-20 00:03:49 +00:00
Justin Hibbits
ed03d62a4c Remove fdt fixups for powerpc, they are no longer needed.
If a fixup really is needed, it should be fixed in u-boot, not in FreeBSD.

Suggested by:	nwhitehorn
2018-01-13 02:56:09 +00:00
Alexander Kabaev
151ba7933a 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
2017-12-25 04:48:39 +00:00
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
Marcin Wojtas
bfd084c8c4 Enable parsing simple-bus 'ranges' with multiple entries
This patch makes possible to boot with up to 8 ranges in soc.
Dynamic allocation cannot be used, because ftd_get_ranges
function is called early, when malloc is not available.

Change is required for the alignment of Marvell Armada 38x
device trees present in sys/gnu/dts/arm - originally
the platform has 6 entries in simple-bus 'ranges'.

Submitted by: Patryk Duda <pdk@semihalf.com>
Reviewed by: manu, nwhitehorn, cognet (mentor)
Approved by: cognet (mentor)
Obtained from: Semihalf
Differential Revision: https://reviews.freebsd.org/D11876
2017-08-09 00:45:25 +00:00
Luiz Otavio O Souza
948dad6add Set the correct default for #address-cells variable when the property does
not exist.

This has never caused any issue because #address-cells is mandatory.

Sponsored by:	Rubicon Communications, LLC (Netgate)
MFC after:	2 weeks
2017-04-30 07:31:48 +00:00