Update syscall validation handlers to only validate that API != NULL
if the API is required. Optional APIs have runtime NULL checks in
their implementations, so only permissions and subsystem type needs
to be validated.
Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
Register structs rely on the compiler emitting 32-bit volatile accesses
and on the struct layout staying in sync with the hardware. sys_read32
and sys_write32 make the access width explicit, work with DEVICE_MMIO
address mapping, and match the convention used by in-tree drivers.
Signed-off-by: Daniel Schultz <dnltz@aesc-silicon.de>
Make gpio_aesc_dev_cfg_##no "static const struct" instead of
"static struct" to move this struct into ROM. This reduces the
memory usage for this driver.
Signed-off-by: Daniel Schultz <dnltz@aesc-silicon.de>
Use <> operator to include a Zephyr header file instead of "" that
is intended to local header files, not header files relative to
specifically defined search paths.
This change was made running the sed shell command below:
$ sed -i -E 's/#include "zephyr\/([^"]+)\.h"/#include <zephyr\/\1.h>/g' \
`grep -rsl "#include \"zephyr/" drivers/`
Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
Add the missing open drain support for the families that support it.
Tested with the zephyr,1w-gpio driver on kinetis k66
Signed-off-by: Karl Palsson <karl.palsson@marel.com>
- Enables the digital input buffer for both input and
output pins so the pin level can always be read back.
- Aligns the RT700 GPIO driver with the rest of NXP GPIO
drivers' behavior.
- The read-back is required by self-test routines.
Signed-off-by: Andrej Butok <andrey.butok@nxp.com>
Add a GPIO expander driver for the Raspberry Pi BCM283x, using
the VideoCore firmware property interface.
Signed-off-by: Muhammad Waleed Badar <walid.badar@gmail.com>
Add support for output open drain mode which is used by the tests in
`tests/drivers/gpio/gpio_basic_api/`.
While there, switch some magic numbers to the corresponding HAL
defines and be stricter on invalid or unsupported configurations.
Signed-off-by: Michael Hope <michaelh@juju.nz>
Add missing k_spin_unlock() calls on error return paths in
gpio_altera_configure() and gpio_altera_pin_interrupt_configure().
Both functions returned -EINVAL in their default/else branches
while still holding the spinlock acquired earlier.
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
These drivers were used by Series 2 SoCs before they were migrated from
gecko_sdk to simplicity_sdk. Currently, Series 2 SoCs don't use them
anymore. In fact, their Kconfig dependencies don't even allow using them
for simplicity_sdk based SoCs.
Removing the leftovers simplifies the code and is a preparation for larger
changes in soc.c.
Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
`DEVICE_MMIO_ROM/RAM` must be the first field in a struct, but the
GPIO API uniquely requires `gpio_driver_config/data` to be first.
This commit extends the changes made in PR #108244 to
the renesas_rza2m GPIO driver by switching to the named MMIO variants.
This allows the MMIO data to be safely placed in subsequent
fields for both ROM and RAM initializations.
Signed-off-by: Akansh Sinha <akansh.sinha.dev@gmail.com>
The iMX GPIO IMR and ISR registers are not reset by a warm reset.
If a pin had its interrupt enabled in a previous boot, it remains
active after reset. This causes a spurious ISR to fire the moment
irq_enable() is called during driver init, before any Zephyr driver
has called gpio_pin_interrupt_configure() for that pin.
Fix this by: (1) clearing IMR to 0 to disable all interrupt sources,
(2) writing 0xFFFFFFFF to ISR (write-1-to-clear) to flush
any pending interrupt flags — all before irq_enable().
Tested with tests/drivers/gpio/gpio_basic_api for
mimxrt1020_evk.
Fixes#108056
Signed-off-by: Jason Yu <zejiang.yu@nxp.com>
- Kconfigs in modules/ should not define configs with an SOC_ prefix.
Furthermore, these options are SDK specific, not SoC specific.
- The simplicity_sdk configs do the same.
Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
For Gen5 SoCs:
- Register offsets are different.
- The direction (either input or output) must be selected.
Signed-off-by: Julien Panis <jpanis@baylibre.com>
Convert the driver clock accesses to use the new generic API, so the
driver can be used on R-Car boards generations 3, 4 and 5 without changes.
Signed-off-by: Adrien Ricciardi <aricciardi@baylibre.com>
The Zephyr GPIO subsystem requires struct gpio_driver_config and
struct gpio_driver_data as the first members of the driver's config
and data structs respectively, since the subsystem casts pointers
to these types directly. Initialize port_pin_mask from devicetree.
Switch DEVICE_MMIO to named variants since the unnamed macros assume
MMIO is the first struct member, which is no longer the case.
Also fix DEV_CFG to return a const pointer.
Signed-off-by: Daniel Schultz <dnltz@aesc-silicon.de>
Don't write to "DEVICE_MMIO_GET(dev)". Instead, store the register
base address in the data struct and use it for accessing the
registers later.
Signed-off-by: Daniel Schultz <dnltz@aesc-silicon.de>
Implements interrupt support for the AESC GPIO driver.
Adds pin_interrupt_configure handling level (high/low) and edge
(rising/falling/both) trigger modes with proper
pending-clear-before-enable sequencing, manage_callback for
registering GPIO callbacks, and an ISR that aggregates all four
pending interrupt sources, clears them, and fires registered
callbacks. IRQ registration is done via a config function pointer
initialized at boot.
Signed-off-by: Daniel Schultz <dnltz@aesc-silicon.de>
Select the gpio1 register field layout used by C5/C6/H2 on P4 and
switch the device definition to DEVICE_DT_INST_DEFINE.
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
Expose the M5PM1 GPIO bank as a Zephyr GPIO controller child of the MFD
device. The driver supports five pins with input/output configuration,
pull-up/pull-down, and open-drain outputs; pin interrupts are not
supported.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:opus-4.7
Updates the SoC initialization to configure PSRAM IO GLB register such that
PSRAM GPIO registers (32-37) are reused for pins whose registers are
allocated for SF2 internal flash (23-28), and modifies the GPIO driver to
use those offset registers when configuring.
Signed-off-by: Dan Mangum <georgedanielmangum@gmail.com>
Co-authored-by: Camille BAUD <mail@massdriver.space>
Adds the missing config member that is common to all GPIO drivers
and that is expected to be the first element in the object pointed
to by the config field in the device structure.
Signed-off-by: Jesse Hörkkö <jesse.horkko@sasken.com>
PA39-PA42 reuse bit 8 as MODE instead of slew rate. The GPIO
driver always set bit 8, which forced those pads into I2C mode
whenever they were configured as GPIOs.
Configure GPIO pads with read-modify-write, clear MODE on PA39-PA42
to select GPIO mode, and stop modifying bit 8 on other pads. Slew
rate is now left to pinctrl or hardware defaults instead of the GPIO
configuration path.
Signed-off-by: Haoran Jiang <halfsweet@halfsweet.cn>
Wake-up feature should be available even if user selects only
POWEROFF function. PM and PM_DEVICE are related to IDLE and
also possibly with calling PM_STATE_SOFT_OFF, so it is kept
as check/guard for the wake-up function as well.
Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
Update all drivers to use "flags" instead of "sense" when accessing
interrupt properties from device tree. This aligns with the updated
interrupt controller bindings that now consistently use "flags" as
the cell name for the IRQ type field.
Signed-off-by: Amneesh Singh <amneesh@ti.com>
The GPIO subsystem forwards GPIO_INT_WAKEUP from dt_flags into the trig
argument of pin_interrupt_configure(). Wakeup source configuration is
already handled in gpio_esp32_config(); strip the bit before passing trig
to convert_int_type() to avoid -EINVAL return.
Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
The MFX does not natively support BOTH direction edge
detection. In order to support it, adapt the requested edge
depending on the level at configuration time and toggle the
edge whenever an interrupt is received.
Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
So far the driver was setting the PU/PD bit properly however
missed setting another bit indicating of a Pull-Down or Pull-Up
are necessary.
Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
Remove the redundant cast to struct device * from struct device * in
some of the GPIO API syscall handlers in gpio_handlers.c
Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
The following APIs
- gpio_port_set_masked()
- gpio_port_set_bits()
- gpio_port_clear_bits()
- gpio_port_set_clr_bits_raw()
- gpio_port_set_clr_bits()
- gpio_pin_get_raw()
- gpio_pin_get()
- gpio_pin_set_raw()
- gpio_pin_set()
- gpio_pin_toggle()
are currently not syscalls, while the following are:
- gpio_port_set_bits_raw()
- gpio_port_get_raw()
It is therefore possible to set and get any pin of the entire port
from userspace, but only through a few of the APIs.
These APIs should all be either syscalls, or not syscalls.
Align the APIs so they are all syscalls and add syscall handlers for
them in gpio_handler.c
Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
The GPIO_DDR register uses 1 for output mode and 0 for input mode.
The previous implementation incorrectly swapped these values, causing
gpio_pin_is_input() and gpio_pin_is_output() to return wrong results.
Also mask out unconnected pins using connect_pin to ensure
disconnected GPIOs are not reported as either input or output.
Fixes gpio_get_direction test failures on RTL87x2G and RTL8752H series.
Signed-off-by: Yuzhuo Liu <yuzhuo_liu@realsil.com.cn>
Use the optional clocks property to request the GPIO port clock
during driver initialization.
This lets RT7xx GPIO instances rely on the common clock control
path instead of board-specific clock enabling.
Signed-off-by: Zhaoxiang Jin <Zhaoxiang.Jin_1@nxp.com>
Fix a typo in mcux_igpio_configure() for CONFIG_SOC_MIMX8MQ6_M4
where `flag` was used instead of `flags` when checking
GPIO_PULL_DOWN.
Signed-off-by: Paolo Wattebled <paolo.wattebled@savoirfairelinux.com>
Add a driver for the Diodes/Pericom PI4IOE5V6408 8-bit I2C-bus I/O
expander.
The chip provides eight independently configurable GPIO lines, each
with optional pull-up or pull-down resistor and an interrupt source
that fires on transitions away from a programmable default state.
Link: https://www.diodes.com/datasheet/download/PI4IOE5V6408.pdf
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
- Enables input buffer via Software Input On (SION)
to get correct pin value in PDIR for both input/output pins
for IMXRT118X.
- Issue has been discovered during Safety DIO self-tests.
Signed-off-by: Andrej Butok <andrey.butok@nxp.com>
Coming with nrfx 4.3, NRF_GPIO_HAS_DETECTMODE is now
defned only when it is actually accessible.
Removed the hidden Kconfig option and used
nrfx symbol only.
Signed-off-by: Michał Stasiak <michal.stasiak@nordicsemi.no>
Add a generic GPIO driver for a memory-mapped output latch register.
Include the driver implementation and devicetree binding.
Also add the required Kconfig and CMake integration.
Signed-off-by: Zhaoming Li <lizhaoming634@gmail.com>
Added latch detection mode based on DTS property.
Required register is inaccessible in non-secure
builds and on nRF54H20 SoC. Added hidden Kconfig
to guard it.
Signed-off-by: Michał Stasiak <michal.stasiak@nordicsemi.no>
Next-generation it51xxx SoCs support more than 256 irqs.
This change extends irq range up to 16 bit depend on
CONFIG_NUM_IRQS.
And the it8xxx2 SoC series only supports 8-bit irq
number size. Add irq type check assertion for this
series.
Tested with:
- it82xx2_evb/it8xxx2_evb/it51xxx_evb_it51526aw:
tests/drivers/gpio/gpio_basic_api
- native_sim/native:
tests/drivers/gpio/gpio_ite_it8xxx2_v2
Signed-off-by: Ren Chen <Ren.Chen@ite.com.tw>