Commit graph zephyr/drivers/gpio
Author SHA1 Message Date
Steven Chang
b6b79411bc drivers: gpio: kb106x: GPIO api bugs fix
- Fix gpio_port_set_masked_raw api bug.
- Fix gpio_pin_interrupt_configure race condition bug

Signed-off-by: Steven Chang <steven@ene.com.tw>
2026-07-03 13:56:06 -04:00
Bjarki Arge Andreasen
f05eb3992f drivers: gpio: handlers: Only validate API if APIs must != NULL
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>
2026-07-03 13:53:16 +02:00
Daniel Schultz
a6740503a8 drivers: gpio: gpio_aesc: Convert to sys_{write,read}32
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>
2026-07-02 12:58:32 -04:00
Daniel Schultz
154b083e9d drivers: gpio: gpio_aesc: Add const to config struct
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>
2026-07-02 12:58:32 -04:00
Etienne Carriere
b0b25c35c9 drivers: use <> to include Zephyr headers instead of ""
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>
2026-06-30 06:49:18 -04:00
Karl Palsson
4b3d6fa041 drivers/gpio/gpio_mcux: support single ended mode when available
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>
2026-06-26 14:24:47 +01:00
Andrej Butok
e8200a7d7e gpio: gpio_mcux: nxp: rt700: enable digital input buffer
- 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>
2026-06-26 07:48:37 -04:00
Muhammad Waleed Badar
3275bbe6ed drivers: gpio: add raspberry pi bcm283x GPIO expander driver
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>
2026-06-25 06:16:31 -04:00
5fa48e776d drivers: gpio: ch32v00x: add output open drain support
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>
2026-06-25 06:16:10 -04:00
Brian Cain
abb0fba2f9 drivers: gpio: fix spinlock leak in gpio_altera_pio
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>
2026-06-19 14:54:44 +02:00
Michael Zimmermann
2f0ac8cbd2 tree-wide: remove silabs Series 2 code from Series 0/1 drivers
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>
2026-06-19 13:19:43 +02:00
Akansh Sinha
e898a3fd27 drivers: gpio: renesas_rza2m: fix register base
`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>
2026-06-19 13:18:35 +02:00
Jason Yu
6b6ba345fd drivers: gpio: mcux_igpio: clear stale interrupt state on init
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>
2026-06-18 07:59:38 +02:00
Anas Nashif
ea1fbf3588 driver: fix various typos
Fixed various typos under drivers/

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-06-17 10:12:27 -04:00
Michael Zimmermann
8a7ae0bed1 modules: hal_silabs: rename gecko kconfigs
- 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>
2026-06-17 08:05:45 +02:00
Julien Panis
25874ade6f drivers: gpio_rcar: Make driver usable with Gen5
For Gen5 SoCs:
- Register offsets are different.
- The direction (either input or output) must be selected.

Signed-off-by: Julien Panis <jpanis@baylibre.com>
2026-06-15 12:13:17 -04:00
Adrien Ricciardi
7d59a66eb3 drivers: gpio: Add pinctrl support to the R-Car GPIO driver
This is required on modern Zephyr to configure appropriately the pins
for GPIO operations.

Signed-off-by: Adrien Ricciardi <aricciardi@baylibre.com>
2026-06-15 12:13:17 -04:00
Adrien Ricciardi
31b577827f drivers: gpio: Add generic clock support to the R-Car GPIO driver
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>
2026-06-15 12:13:17 -04:00
Daniel Schultz
5b87d56a1d drivers: gpio: aesc: add missing common config and data fields
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>
2026-06-12 07:49:34 +02:00
Daniel Schultz
6bb13a76a2 drivers: gpio: aesc: Properly relocate register base
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>
2026-06-12 07:49:34 +02:00
Daniel Schultz
cb4106416b drivers: gpio: aesc: Fix Copyright Text
Use "SPDX-FileCopyrightText" for the copyright holder.

Signed-off-by: Daniel Schultz <dnltz@aesc-silicon.de>
2026-06-12 07:49:34 +02:00
Daniel Schultz
8998d528c0 drivers: gpio: aesc: Add Interrupt Support
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>
2026-06-08 21:29:17 -04:00
Sylvio Alves
f101f519c6 drivers: gpio: esp32: add esp32p4 support
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>
2026-06-03 18:27:15 -04:00
Benjamin Cabé
5a231ea4d9 drivers: gpio: add GPIO driver for M5Stack M5PM1 PMIC
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
2026-06-02 20:18:46 -04:00
Dan Mangum
4031347d17 drivers: gpio: bflb: use offset GPIO registers for internal flash pins
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>
2026-06-02 20:21:10 +02:00
Jesse Hörkkö
f5c7c424c0 drivers: gpio: max149x6: add missing common config member
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>
2026-06-02 09:26:31 -05:00
Haoran Jiang
c31178a967 drivers: gpio: sf32lb: fix PA39-PA42 mode handling
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>
2026-06-02 13:27:59 +02:00
Raffael Rostagno
b147f5e76c drivers: gpio: esp32: Update PM compile guards
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>
2026-06-01 12:41:59 -04:00
Amneesh Singh
9969745801 drivers: update interrupt handling to use "flags" instead of "sense"
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>
2026-06-01 12:38:26 -04:00
Raffael Rostagno
2a0650072e drivers: gpio: esp32: Handle GPIO_INT_WAKEUP in pin_interrupt_configure
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>
2026-05-29 07:45:26 +02:00
Alain Volmat
d0a08f6cb7 drivers: gpio: mfxstm32l152: add BOTH EDGE trigger support
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>
2026-05-29 07:36:55 +02:00
Alain Volmat
d9a32d3395 drivers: gpio: mfxstm32l152: correct PU/PD handling
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>
2026-05-29 07:36:55 +02:00
Alain Volmat
a51f00c81a drivers: gpio: mfxstm32l152: simplify PUPD/Direction handling
Simplify the way bit handling for direction and PullUp/PullDown
control is done.

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
2026-05-29 07:36:55 +02:00
Bjarki Arge Andreasen
18fef60e35 drivers: gpio: handlers: remove redundant cast to struct device *
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>
2026-05-29 07:35:53 +02:00
Bjarki Arge Andreasen
02657c2971 include: drivers: gpio: make gpio_pin_* APIs syscalls
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>
2026-05-29 07:35:53 +02:00
Daniel Schultz
aca1beaa5b drivers: gpio: aesc: Add pinctrl
Apply pinctrl settings during the init function.

Signed-off-by: Daniel Schultz <dnltz@aesc-silicon.de>
2026-05-27 08:34:52 +02:00
cyliang tw
dc5f98e241 drivers: pinctrl & gpio: modify numaker driver for m031x support
Modify gpio_numaker.c & pinctrl_numaker.c for SOC_SERIES_M031X support.

Signed-off-by: cyliang tw <cyliang@nuvoton.com>
2026-05-25 18:18:15 +02:00
Yuzhuo Liu
ef185cbe6a drivers: gpio: fix bee gpio direction detection
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>
2026-05-24 18:35:47 -07:00
Zhaoxiang Jin
afefde1f80 gpio: mcux: add reset controller support
add reset controller support

Signed-off-by: Zhaoxiang Jin <Zhaoxiang.Jin_1@nxp.com>
2026-05-22 18:23:27 +02:00
Zhaoxiang Jin
f488ca84c7 gpio: mcux: enable clocks from devicetree
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>
2026-05-22 18:23:27 +02:00
Paolo Wattebled
42a6663502 drivers: gpio: mcux_igpio: fix flags typo
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>
2026-05-18 18:40:45 +02:00
Carlo Caione
6084fe8903 drivers: gpio: add PI4IOE5V6408 driver
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>
2026-05-18 15:20:20 +01:00
Andrej Butok
12a0137b3a drivers: gpio: nxp: mcux_rgpio: fix mcux_rgpio_configure()
- 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>
2026-05-14 21:55:44 +02:00
Michał Stasiak
eaa479eace driver: gpio_nrfx: Remove config option for latch detection
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>
2026-05-14 15:16:07 +02:00
Davide Di Lello
82741b2614 drivers: infineon: Update copyright for Infineon
Update structure of the copyright

Signed-off-by: Davide Di Lello <Davide.Dilello@Infineon.com>
2026-05-12 22:19:02 +02:00
Zhaoming Li
64f5fabf2a drivers: gpio: add MMIO latch GPIO driver
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>
2026-05-11 21:03:38 -05:00
Michał Stasiak
b530448c2c drivers: gpio: disable latch detection for nRF92 series
Latch detection is not supported on nRF92 GPIO driver.

Signed-off-by: Michał Stasiak <michal.stasiak@nordicsemi.no>
2026-05-11 15:29:14 +01:00
Michał Stasiak
cf79aa7c90 drivers: gpio: gpio_nrfx: Add support for latch detection
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>
2026-05-11 15:29:14 +01:00
Sergei Ovchinnikov
5d62f0f3d0 drivers: gpio: npm10xx GPIO driver
Nordic's nPM10 Series PMICs' GPIO driver and Devicetree bindings

Signed-off-by: Sergei Ovchinnikov <sergei.ovchinnikov@nordicsemi.no>
2026-05-08 06:49:40 -05:00
Ren Chen
ddba70043d soc: ite: ec: extend irq number size to 16-bit
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>
2026-05-07 09:23:06 +02:00