History log of /freebsd-current/sys/arm/broadcom/bcm2835/bcm2835_gpio.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/


# 9d35469e 28-May-2023 Tetsuya Uemura <t_uemura@macome.co.jp>

bcm2835_gpio: Handle BCM2711 pin configuration

Add support for GPIO internal pull up/down configuration on RPi4 family.

BCM2711 SoC on 4th generation Raspberry Pi changed the way to configure
its GPIO pins' internal pull up/down resistors. NetBSD already have
support for this change, and port it to FreeBSD is trivial.

This patch, based on the NetBSD commit adds the appropriate method for
BCM2711 and now we can properly configure the GPIO pins' pull status.

PR: 256372
Reviewed by: mhorne
Obtained from: NetBSD bb88cfa64ad8
Pull Request: https://github.com/freebsd/freebsd-src/pull/746


# 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


# 82d4dc06 09-May-2022 John Baldwin <jhb@FreeBSD.org>

arm/arm64 broadcom: Remove unused devclass arguments to DRIVER_MODULE.


# 34df2dfa 08-Apr-2022 John Baldwin <jhb@FreeBSD.org>

bcm2835_gpio: Remove unused variable.

This was a static local (i.e. a global variable) which was probably
not intended.


# 2551d928 17-Feb-2021 Emmanuel Vadot <manu@FreeBSD.org>

arm64: rpi4: gpio: Add brcm,bcm2711-gpio compatible

Looks like we never enabled the main gpio controller on the RPI4 board.
Now gpio are usable.

MFC after: 3 days


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

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


# 7029da5c 26-Feb-2020 Pawel Biernacki <kaktus@FreeBSD.org>

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


# 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


# 91cc58af 07-Apr-2018 Oleksandr Tymoshenko <gonzo@FreeBSD.org>

[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


# 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


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

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.


# feabce61 07-Nov-2016 Andrew Turner <andrew@FreeBSD.org>

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


# 0e3cfd98 11-Oct-2016 Oleksandr Tymoshenko <gonzo@FreeBSD.org>

Fix typo in comment

Spotted by: loos


# aa2959ba 11-Oct-2016 Oleksandr Tymoshenko <gonzo@FreeBSD.org>

Make BCM2835 GPIO driver compatible with upstream DT

- Add compatibility string
- Make reserverd and read-only properties optional


# 9346e913 18-May-2016 Andrew Turner <andrew@FreeBSD.org>

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


# bc90a48c 11-May-2016 Oleksandr Tymoshenko <gonzo@FreeBSD.org>

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


# f7f2b2fb 08-May-2016 Svatopluk Kraus <skra@FreeBSD.org>

INTRNG - update gpio pin capabilities according to r299198.


# 6247277a 06-May-2016 Svatopluk Kraus <skra@FreeBSD.org>

INTRNG - support new interrupt mapping type INTR_MAP_DATA_GPIO
introduced in r298738.


# c28b681c 06-May-2016 Svatopluk Kraus <skra@FreeBSD.org>

INTRNG - use gpio interrupt modes definitions added in r298738 and
implement also GPIO_INTR_EDGE_BOTH mode. All reasonable interrupt
modes are supported now.


# cd642c88 05-May-2016 Svatopluk Kraus <skra@FreeBSD.org>

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.


# 59c3cb81 15-Apr-2016 Andrew Turner <andrew@FreeBSD.org>

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


# 89de2fb6 05-Apr-2016 Svatopluk Kraus <skra@FreeBSD.org>

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


# 5508fc88 17-Feb-2015 Luiz Otavio O Souza <loos@FreeBSD.org>

Make use of the newly introduced macros.

Update the copyright.


# 12471cec 04-Feb-2015 Luiz Otavio O Souza <loos@FreeBSD.org>

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


# e74d6e2a 04-Feb-2015 Luiz Otavio O Souza <loos@FreeBSD.org>

Sort and remove unnecessary includes.


# 7836352b 31-Jan-2015 Luiz Otavio O Souza <loos@FreeBSD.org>

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.


# c2136589 30-Jan-2015 Luiz Otavio O Souza <loos@FreeBSD.org>

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.


# 99a20111 30-Jan-2015 Luiz Otavio O Souza <loos@FreeBSD.org>

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.


# 667357dc 18-Nov-2014 Luiz Otavio O Souza <loos@FreeBSD.org>

Moves all the duplicate code to a single function.

Verify for invalid modes and unwanted flags before pass the new flags to
driver.


# 61c009a1 18-Nov-2014 Warner Losh <imp@FreeBSD.org>

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


# 8839e0e9 28-Oct-2014 Luiz Otavio O Souza <loos@FreeBSD.org>

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.


# 8c705c2c 13-Feb-2014 Luiz Otavio O Souza <loos@FreeBSD.org>

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)


# add35ed5 02-Feb-2014 Ian Lepore <ian@FreeBSD.org>

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.


# 1fbabb48 06-Dec-2013 Luiz Otavio O Souza <loos@FreeBSD.org>

Make the sysctl node read-only.

Approved by: adrian (mentor)


# 64894120 26-Oct-2013 Ian Lepore <ian@FreeBSD.org>

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.


# 09b2544b 25-Oct-2013 Luiz Otavio O Souza <loos@FreeBSD.org>

Remove all the instances of '#undef DEBUG' from kernel.

Suggested by: rpaulo
Approved by: adrian (mentor)


# 44d06d8d 07-Sep-2013 Luiz Otavio O Souza <loos@FreeBSD.org>

Export a function to allow BCM2835's peripheral devices to enable their
altenate pin function (from GPIO pins) as needed.

Approved by: adrian (mentor)


# 8d900240 06-Sep-2013 Luiz Otavio O Souza <loos@FreeBSD.org>

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


# 27e644a8 13-Apr-2013 Dimitry Andric <dim@FreeBSD.org>

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


# 90576f54 18-Dec-2012 Oleksandr Tymoshenko <gonzo@FreeBSD.org>

Add sysctls for changing GPIO pins function

Submitted by: Luiz Otavio O Souza


# 4063f925 23-Nov-2012 Oleksandr Tymoshenko <gonzo@FreeBSD.org>

Add Raspberry Pi GPIO driver

Submitted by: Luiz Otavio O Souza