Commit Graph

37 Commits

Author SHA1 Message Date
Mateusz Guzik
654548838b arm: clean up empty lines in .c and .h files 2020-09-01 21:17:24 +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
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
Oleksandr Tymoshenko
91cc58af37 [rpi] Add fdt_pinctrl(4) support to Raspberry Pi GPIO driver
On Raspberry Pi platform GPIO controller also responsible for pins
multiplexing. Pi code predates proper FDT support in FreeBSD so a
lot of pinmux info is hardcoded. This patch:

- Implements pinctl methods in bcm2835_gpio
- Converts all devices with ad-hoc pinmux info to proper pin control
  mechanisms and adds pinmux info in FreeBSD's custom dts files.
- Adds fdt_pinctrl option to RPI2 and RPI-B kernels
- Adds SPI pinmux config to FreeBSD's customization of GNU DTS.

Reviewed by:	imp, manu
Differential Revision:	https://reviews.freebsd.org/D14104
2018-04-08 00:56:19 +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
af3dc4a7ca sys/arm: 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 15:04:10 +00:00
Andrew Turner
feabce61dc Start to remove the old pre-INTRNG code from the arm platforms. These have
all moved to use INTRNG.

Reviewed by:	manu, mmel
Sponsored by:	ABT Systems Ltd
Differential Revision:	https://reviews.freebsd.org/D8469
2016-11-08 12:15:57 +00:00
Oleksandr Tymoshenko
0e3cfd98fc Fix typo in comment
Spotted by: loos
2016-10-12 05:35:57 +00:00
Oleksandr Tymoshenko
aa2959bae5 Make BCM2835 GPIO driver compatible with upstream DT
- Add compatibility string
- Make reserverd and read-only properties optional
2016-10-12 03:06:05 +00:00
Andrew Turner
9346e9130d Return the struct intr_pic pointer from intr_pic_register. This will be
needed in later changes where we may not be able to lock the pic list lock
to perform a lookup, e.g. from within interrupt context.

Obtained from:	ABT Systems Ltd
Sponsored by:	The FreeBSD Foundation
2016-05-18 15:05:44 +00:00
Oleksandr Tymoshenko
bc90a48ccf Add OF_prop_free function as a counterpart for OF_*prop_alloc
- Introduce new OF API function OF_prop_free to free memory allocated by
  OF_getprop_alloc and OF_getencprop_alloc. Current code just calls free(9)
  with M_OFWPROP memory class which assumes knowledge about OF_*prop_alloc
  functions' internals and leads to unneccessary code coupling

- Convert some of the free(..., M_OFWPROP) instances to OF_prop_free

Files affected by this commit are the ones I was able to test on real
hardware. The rest of free(..., M_OFWPROP) instances will be handled with
idividual maintainers

Reviewed by:	andrew
Differential Revision:	https://reviews.freebsd.org/D6315
2016-05-11 18:20:02 +00:00
Svatopluk Kraus
f7f2b2fbe3 INTRNG - update gpio pin capabilities according to r299198. 2016-05-08 09:01:30 +00:00
Svatopluk Kraus
6247277a02 INTRNG - support new interrupt mapping type INTR_MAP_DATA_GPIO
introduced in r298738.
2016-05-06 20:57:41 +00:00
Svatopluk Kraus
c28b681c3e INTRNG - use gpio interrupt modes definitions added in r298738 and
implement also GPIO_INTR_EDGE_BOTH mode. All reasonable interrupt
modes are supported now.
2016-05-06 20:55:14 +00:00
Svatopluk Kraus
cd642c88a1 INTRNG - redefine struct intr_map_data to avoid headers pollution. Each
struct associated with some type defined in enum intr_map_data_type
must have struct intr_map_data on the top of its own definition now.
When such structs are used, correct type and size must be filled in.

There are three such structs defined in sys/intr.h now. Their
definitions should be moved to corresponding headers by follow-up
commits.

While this change was propagated to all INTRNG like PICs,
pic_map_intr() method implementations were corrected on some places.
For this specific method, it's ensured by a caller that the 'data'
argument passed to this method is never NULL. Also, the return error
values were standardized there.
2016-05-05 13:31:19 +00:00
Andrew Turner
59c3cb81c1 Rename ARM_INTRNG and MIPS_INTRNG to INTRNG. This will help with machine
independent code that needs to know about INTRNG such as PCI drivers.

Obtained from:	ABT Systems Ltd
Sponsored by:	The FreeBSD Foundation
2016-04-15 16:05:41 +00:00
Svatopluk Kraus
89de2fb6d4 Rework BCM283x gpio interrupt controller for INTRNG. It's used on RPI-B
and RPI2 where INTRNG is already enabled by default.

Differential Revision:	https://reviews.freebsd.org/D5810
2016-04-05 13:45:23 +00:00
Luiz Otavio O Souza
5508fc88ba Make use of the newly introduced macros.
Update the copyright.
2015-02-17 20:37:21 +00:00
Luiz Otavio O Souza
12471cec7c Add GPIO interrupt support for BCM2835 (Raspberry pi).
With this commit any of the GPIO pins can now be programmed to act as an
interrupt source for GPIO devices (i.e. limited to devices directly
attached to gpiobus - at least for now).

Differential Revision:	https://reviews.freebsd.org/D1000
2015-02-04 18:15:28 +00:00
Luiz Otavio O Souza
e74d6e2a12 Sort and remove unnecessary includes. 2015-02-04 17:23:02 +00:00
Luiz Otavio O Souza
7836352b50 Implement GPIO_GET_BUS() method for all GPIO drivers.
Add helper routines to deal with attach and detach of gpiobus and gpioc
devices that are common to all drivers.
2015-01-31 19:32:14 +00:00
Luiz Otavio O Souza
c213658943 The BCM2835 GPIO controller uses has interrupt lines and not only one.
Allocate all four, we will use them soon.

Simplificate the allocation of memory and interrupt resources with a single
bus_alloc_resources() call instead of doing them separately.

Destroy the mutex in case of errors.
2015-01-30 18:18:09 +00:00
Luiz Otavio O Souza
99a2011188 Allow the retrieving of the reserved pins state.
With this change, it is now possible to verify the pin function and level
of reserved pins (but not set them).

The use of reserved pins on Raspberry pi can lead to short circuits and
real damage to the SoC.

While here, remove duplicated code, make use of OF_getencprop_alloc()
instead of using fixed sized variables and reduce the dmesg spam by
printing reserved pin ranges (when possible) instead of printing each pin
in the range.
2015-01-30 14:35:04 +00:00
Luiz Otavio O Souza
667357dc9b Moves all the duplicate code to a single function.
Verify for invalid modes and unwanted flags before pass the new flags to
driver.
2014-11-18 17:22:08 +00:00
Warner Losh
61c009a1a8 These delays aren't needed. Elimate them. They should be on the order
of a few cycles at most, not 10us. They make it impossible to
implement half-duplex protocols that are faster than about 1KHz.

Sponsored by: Netflix
2014-11-18 17:07:02 +00:00
Luiz Otavio O Souza
8839e0e9f3 Make the GPIO children attach to the first unit available and not only to
unit 0.

It seems that this 'simplification' was copied to all GPIO drivers in tree.

This fix a bug where a GPIO controller could fail to attach its children
(gpioc and gpiobus) if another GPIO driver attach first.
2014-10-28 18:33:59 +00:00
Luiz Otavio O Souza
8c705c2c30 Allow the use of the OFW GPIO bus for ti_gpio and bcm2835_gpio. With this
change the gpio children can be described as directly connected to the GPIO
controller without the need of describing the OFW GPIO bus itself on the
DTS file.

With this commit the OFW GPIO bus is fully functional on BBB and RPi.

GPIO controllers which want to use the OFW GPIO bus will need similar
changes.

Approved by:	adrian (mentor, implicit)
2014-02-13 18:42:23 +00:00
Ian Lepore
add35ed5b8 Follow r261352 by updating all drivers which are children of simplebus
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.
2014-02-02 19:17:28 +00:00
Luiz Otavio O Souza
1fbabb4886 Make the sysctl node read-only.
Approved by:	adrian (mentor)
2013-12-06 17:45:14 +00:00
Ian Lepore
6489412064 Remove #include <machine/frame.h> from all the arm code that doesn't
really need it.  That would be almost everywhere it was included.  Add
it in a couple files that really do need it and were previously getting
it by accident via another header.
2013-10-27 01:34:10 +00:00
Luiz Otavio O Souza
09b2544b71 Remove all the instances of '#undef DEBUG' from kernel.
Suggested by:	rpaulo
Approved by:	adrian (mentor)
2013-10-25 18:38:44 +00:00
Luiz Otavio O Souza
44d06d8d9a Export a function to allow BCM2835's peripheral devices to enable their
altenate pin function (from GPIO pins) as needed.

Approved by:	adrian (mentor)
2013-09-07 18:48:15 +00:00
Luiz Otavio O Souza
8d900240b0 Fix an off-by-one bug in ar71xx_gpio and bcm2835_gpio which makes the last
pin unavailable.

Reported and tested by:	sbruno (ar71xx)
Approved by:	adrian (mentor)
Pointy hat to:	loos
2013-09-06 23:39:56 +00:00
Dimitry Andric
27e644a80b Fix undefined behaviour in several gpio_pin_setflags() routines (under
sys/arm and sys/mips), squelching the clang 3.3 warnings about this.

Noticed by:	tinderbox and many irate spectators
Submitted by:	Luiz Otavio O Souza <loos.br@gmail.com>
PR:		kern/177759
MFC after:	3 days
2013-04-13 21:21:13 +00:00
Oleksandr Tymoshenko
90576f541b Add sysctls for changing GPIO pins function
Submitted by:	Luiz Otavio O Souza
2012-12-18 22:18:54 +00:00
Oleksandr Tymoshenko
4063f92555 Add Raspberry Pi GPIO driver
Submitted by:	Luiz Otavio O Souza
2012-11-23 20:04:39 +00:00