| Age | Commit message (Collapse) | Author |
|
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D53407
|
|
The wrapper functions such as bus_alloc_resource_any() still support
passing the rid by value or pointer, but the underlying implementation
now passes by value.
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D53402
|
|
Implement bus_child_deleted and attach the gpio_aei dev to it's ACPI
handle.
Reviewed by: wulf
Differential Revision: https://reviews.freebsd.org/D51585
|
|
Use bus_generic_detach instead of bus_detach_children so the children
actually get deleted.
Reviewed by: jhb
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D52305
|
|
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D53193
|
|
Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D52045
|
|
This slipped through after I resolved some merge conflicts.
Fixes: d000adfe
MFC after: 1 day
|
|
A race can occur in gpioc_ioctl when it is called with GPIOCONFIGEVENTS
closely followed by GPIOSETCONFIG. GPIOSETCONFIG can alter the
priv->pins list, making it no longer empty and opening the door for
access to priv->events while we are reallocating it. Fix this by holding
priv->mtx while handling GPIOCONFIGEVENTS.
Reported by: Qiu-ji Chen
PR: 289120
Reviewed by: mmel
MFC after: 1 day
Differential Revision: https://reviews.freebsd.org/D52783
|
|
MFC after: 1 day
|
|
Implement bus_setup_intr and bus_teardown_intr as bus_generic_setup_intr
and bus_generic_teardown_intr respectively for GPIO drivers that support
interrupts. This allows children to setup interrupts.
Reported by: Evgenii Ivanov <devivanov@proton.me>
Reviewed by: imp
MFC after: 1 day
Differential Revision: https://reviews.freebsd.org/D52197
|
|
The function is never called with onoff = -1
MFC after: 3 days
MFC with: 9ae3c30
|
|
Add hint.gpioled.%d.invmode to allow setting the pin inversion method. Accept
the following values:
- auto Use hardware pin inversion if available, else fallback to software pin
inversion.
- hw Use hardware pin inversion.
- sw Use software pin inversion.
Default is auto. This hint is ignored when no pin inversion is
requested (hint.gpioled.%d.invert=0).
Signed-off-by: Stéphane Rochoy <stephane.rochoy@stormshield.eu>
Sponsored-by: Stormshield
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1805
|
|
gpioc never has any children, so there's no need to call these.
Reviewed by: jhb
Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D51933
|
|
With gpioc being a direct child of the GPIO controller, it can't
allocate interrupts properly. It currently allocates interrupts using
it's parent dev (gpioX). This causes problems since the call never goes
through gpiobus. Instead, make gpioc a child of gpiobus and allocate
interrupts using our own dev. Also don't misuse pin->flags, it's not
meant to store the flags from sys/gpio.h
Reported by: Evgenii Ivanov <devivanov@proton.me>
Reviewed by: mmel
Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D51932
|
|
While most GPIO controllers provide pins from 0 .. N in a sequential
manner, not all controllers start with pin 0, and not all controllers
order their pins sequentially. Allow callers to get a pin list from the
controller. The default behaviour is to fill pin_list with pins 0 to
GPIO_PIN_MAX().
Suggested by: mmel
Reviewed by: mmel
Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D52172
|
|
gpioc normally depends on gpioc_cdevpriv_dtor to call
gpioc_release_pin_intr when it's done with a pin. However, if
gpioc_allocate_pin_intr fails, the pin is never added to the linked list
which the destructor loops over to free the pins. Make it so
gpioc_allocate_pin_intr cleans up after itself if it fails.
Reported by: Evgenii Ivanov <devivanov@proton.me>
Approved by: imp (mentor, implicit)
Differential Revision: https://reviews.freebsd.org/D51998
|
|
Add pin_config_32 and pin_access_32 to the gpiobus interface. These work
like the rest of the gpiobus interface. For example, if a child has the
following pins in it's ivars: {2, 7 ... 38} calling these functions with
pin 1 will configure/access pins 7 - 38 on the controller.
Reviewed by: mmel
Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D51931
|
|
Approved by: imp (mentor, implicit)
|
|
Reviewed by: imp, andrew
Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D51586
|
|
Rework gpioaei to make it support more than one pin per GPIO resource.
Also allow one instance of gpioaei to handle multiple resources.
Reviewed by: imp, jhb
Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D51584
|
|
Move common bus_add_child code to gpiobus_add_child_common.
Reviewed by: andrew
Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D51582
|
|
Reviewed by: imp
Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D51587
|
|
Since gpiobus_attach_bus can attach the gpiobus child along with its
children in the same bus pass, the parent controller's reference to
gpiobus might not be set by the time the children need it. Instead,
drivers should use gpiobus_add_bus and explicitly call
bus_attach_children.
Reviewed by: mmel, imp (older version)
Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D51578
|
|
Unmap the IRQ instead of just freeing the map data in the case of an
error. Also don't overwrite the resource's virtual address since the
copy of the map data made by intr_activate_irq is stored there.
Implement gpiobus_release_resource so it can unmap IRQs mapped by
gpio_alloc_intr_resource.
Reviewed by: imp
Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D51325
|
|
GPIO controllers aren't required to have an _AEI object.
Reviewed by: wulf
Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D51236
|
|
Move functions and variables internal to gpiobus to their own header to
avoid namespace pollution and misuse.
Reviewed by: wulf, imp
Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D50872
|
|
gpiobus_release_pin is only meant to be used internally by gpiobus. Use
gpio_pin_release instead.
This also fixes a memory leak since gpio_pin_get_by_ofw_idx returns a
malloc'd pointer, which gpio_pin_release now frees.
Reviewed by: wulf, imp
Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D50871
|
|
In some cases, drivers may need to acquire an existing gpio_pin_t. With
the functions gpiobus currently exposes, this isn't possible as they
allocate a new pin then acquire that. Add a new gpio_pin_acquire
function which accepts an existing gpiobus_pin structure.
Reviewed by: mmel, imp
Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D50869
|
|
Reviewed by: mmel, imp
Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D50868
|
|
These are programming errors.
Suggested by: mmel
Reviewed by: imp
Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D50939
|
|
It is a programming error to call this function with an invalid pin.
Also return proper error value on failure.
Suggested by: mmel
Reviewed by: imp, mmel
Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D50940
|
|
Only attach gpiobus when the controller is fully initialized. Children
of gpiobus expect this to be the case.
Reviewed by: mmel, imp, andrew
Approved by: imp (mentor)
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D51088
|
|
Some drivers need to postpone the attachment of gpiobus until hardware
init is done. Add a new gpiobus_add_bus function to accommodate this
case.
Suggested by: mmel, andrew
Reviewed by: mmel, imp, andrew
Approved by: imp (mentor)
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D51133
|
|
Reviewed by: imp, jhb
Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D50913
|
|
Switch to using sys/stdarg.h for va_list type and va_* builtins.
Make an attempt to insert the include in a sensible place. Where
style(9) was followed this is easy, where it was ignored, aim for the
first block of sys/*.h headers and don't get too fussy or try to fix
other style bugs.
Reviewed by: imp
Exp-run by: antoine (PR 286274)
Pull Request: https://github.com/freebsd/freebsd-src/pull/1595
|
|
We call an ACPICA function in the interrupt handler which may attempt to
lock a mutex. If this is done while another instance of the handler
already holds the lock, it would cause a kernel panic since sleeping
isn't allowed.
Reviewed-by: Warner Losh <imp@FreeBSD.org>
Pull-request: https://github.com/freebsd/freebsd-src/pull/1667
Signed-off-by: Ahmad Khalifa <ahmadkhalifa570@gmail.com>
|
|
GPIOBUS_PIN_SETFLAGS calls GPIO_PIN_SETFLAGS, which doesn't accept
interrupt flags.
Reviewed-by: Warner Losh <imp@FreeBSD.org>
Pull-request: https://github.com/freebsd/freebsd-src/pull/1667
Signed-off-by: Ahmad Khalifa <ahmadkhalifa570@gmail.com>
|
|
The flags member of gpio_pin_t was only meant for pin flags acquired via
the FDT.
Instead, make an accessor so gpioaei can still access the flags and
remove the now unused gpio_pin_get_by_acpi_index.
Reviewed-by: Warner Losh <imp@FreeBSD.org>
Pull-request: https://github.com/freebsd/freebsd-src/pull/1667
Signed-off-by: Ahmad Khalifa <ahmadkhalifa570@gmail.com>
|
|
This message was identical to another a few lines up, making it hard to
tell where the error occurred.
Reviewed-by: Ed Maste <emaste@FreeBSD.org>
Reviewed-by: Warner Losh <imp@FreeBSD.org>
Pull-request: https://github.com/freebsd/freebsd-src/pull/1667
Signed-off-by: Ahmad Khalifa <ahmadkhalifa570@gmail.com>
|
|
This method is often used to process GPIO "Power on" button press on
modern x86 laptops with S0ix sleep mode.
Tested with patch from https://reviews.freebsd.org/D26407
Sponsored by: Future Crew LLC
MFC after: 2 month
|
|
Different drivers respond differently to having neither GPIO_PIN_INPUT
or GPIO_PIN_OUTPUT set, this stops the unpredictable results.
|
|
Earlier calls to bus_generic_detach now take care of deleting
children.
Differential Revision: https://reviews.freebsd.org/D47962
|
|
These drivers perform additional teardown steps in between detaching
child devices and deleting child devices.
Differential Revision: https://reviews.freebsd.org/D47957
|
|
When GPIOBUS_PIN_SETFLAGS fails we called gpiobus_free_ivars to clean
up the contents of the ivar, then would free the ivar. This lead to a
use-after-free as the ivar had already been set on the child so
gpiobus_child_deleted would try to free it again.
Fix this by removing the early cleanup and letting
gpiobus_child_deleted handle it.
Fixes: c9e880c0ceef ("gpiobus: Use a bus_child_deleted method to free ivars for children")
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D47670
|
|
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D47675
|
|
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D47674
|
|
No functional change intended.
MFC after: 1 week
|
|
MFC after: 3 days
Reviewed by: ray
Differential Revision: https://reviews.freebsd.org/D47570
|
|
These drivers are not bus drivers, and would need proper detach
routines that tore down state stored in the softc. Better to just
fail detach outright instead of an incorrect success.
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D47389
|
|
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D47369
|