Commit graph

1572 commits

Author SHA1 Message Date
Benjamin Cabé
6176b2ca1b drivers: gpio: wch: simplify port_toggle_bits logic
computation of BSHR was unnecessarily complex, with redundant
XOR/masking operations.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-06-21 15:31:27 +02:00
Hoang Nguyen
87177d1ac4 drivers: gpio: rz: improve gpio driver for Renesas RZ/A2M
- Adding support for GPIO_DISCONNECTED mode.
- Removing redundant interrupt configuration logic from the
.pin_configure API (already handled in pin_interrupt_configure).

Signed-off-by: Hoang Nguyen <hoang.nguyen.jx@bp.renesas.com>
Signed-off-by: Tien Nguyen <tien.nguyen.zg@renesas.com>
2025-06-20 16:24:01 +02:00
Chekhov Ma
7726b70033 drivers: gpio_adp5585: fix input register address
The input register address was somehow missing, fix it.

Signed-off-by: Chekhov Ma <chekhov.ma@nxp.com>
2025-06-18 09:10:55 -04:00
Chekhov Ma
41950cab0f drivers: gpio_adp5585: fix non-contiguous pin layout issue
Fixes #90988. The pin gap handling is wrong in the original code.

Signed-off-by: Chekhov Ma <chekhov.ma@nxp.com>
2025-06-18 09:10:55 -04:00
Youssef Zini
0972b23171 drivers: gpio: add mp2 gpio clock handling
Remove gpio clock management from the GPIO driver when running on the
cortex-m33 on the mp2 and gpio clocks are managed by the cortex-A, being
the resource manager, allowed by the Resource Isolation Framework (RIF).
Also add a specific binding for the mp2 gpio to make clock property
optional.

Signed-off-by: Youssef Zini <youssef.zini@savoirfairelinux.com>
2025-06-17 08:20:33 +02:00
Tien Nguyen
5599bc2ecb drivers: gpio: Add support for RZ/V2N
Add support for RZ/V2N

Signed-off-by: Tien Nguyen <tien.nguyen.zg@renesas.com>
Signed-off-by: Hieu Nguyen <hieu.nguyen.ym@bp.renesas.com>
2025-06-16 14:00:22 -04:00
Khaoula Bidani
a9aa341ed5 drivers: gpio: fix gpio warning
Implement conditional compilation to avoid the warning:
- Use LL_PWR_EnableVDDIO2() for STM32U3 series.
- Use LL_PWR_EnableVddIO2() for other series.

Signed-off-by: Khaoula Bidani <khaoula.bidani-ext@st.com>
2025-06-16 13:59:38 -04:00
Sylvio Alves
2742eb4dc7 driver: gpio: esp32: move config to iram
Make gpio configuration in IRAM area to speed up
access.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2025-06-13 15:40:42 -07:00
Benjamin Cabé
4ad921660f drivers: gpio: rpi_pico: fix typo in gpio_set_dir_masked_n
gpio_set_dir_masked_n on port 1 should manipulate gpio_hi_oe_togl, not
gpio_oe_togl

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-06-13 15:39:50 -07:00
Benjamin Cabé
d9dedff71a drivers: gpio: rpi_pico: route ISR to the right irq_ctrl
gpio_rpi_isr() always addressed io_bank0->proc0_irq_ctrl, so any
interrupts taken while code was running on core 1 were invisible and
left pending.
Use get_core_num() to pick proc1_irq_ctrl when the ISR executes on core
1, ensuring callbacks fire from both cores.
Also fix stray `iobank0_hw` symbol for the correct `io_bank0_hw`.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-06-13 15:39:50 -07:00
Benjamin Cabé
67b4055d57 drivers: gpio: rpi_pico: fix call to gpio_set_dir
Ensure gpio_set_dir() receives GPIO_IN or GPIO_OUT by mapping
INIT_{LOW,HIGH} flags explicitly, instead of passing raw bitmasks.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-06-13 15:39:50 -07:00
Benjamin Cabé
d1fc8c7f29 drivers: gpio: rpi_pico: add missing offsets
Fixed several occurrences of offset not being calculated in case
multiple GPIO ports are present.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-06-13 15:39:50 -07:00
Benjamin Cabé
b10d56e143 drivers: gpio: rpi_pico: fix bad RP2350 ifdef
Fix bad ifdef and typo in rp2350 gpio_configure code.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-06-13 15:39:50 -07:00
S Mohamed Fiaz
f61b5bd705 driver: gpio: siwx91x: Add device runtime support for gpio driver
This commit enables the device runtime driver support
for the siwx91x device.

Signed-off-by: S Mohamed Fiaz <fiaz.mohamed@silabs.com>
2025-06-13 10:08:38 -07:00
Jiafei Pan
47d6f0235a drivers: gpio: rgpio: only handle usable pin's interrupt
If gpio-reserved-ranges to reserve some pins which used by other CPU
Core's OS, we could only handle usable pins owned by current CPU
Core in interrupt handler.

Signed-off-by: Jiafei Pan <Jiafei.Pan@nxp.com>
2025-06-11 18:31:10 -07:00
Jiafei Pan
a6af366eb5 drivers: gpio: rgpio: not support GPIO_DISCONNECTED
The hardware don't support GPIO_DISCONNECTED.

Signed-off-by: Jiafei Pan <Jiafei.Pan@nxp.com>
2025-06-11 18:31:10 -07:00
Jiafei Pan
0971240b5e drivers: gpio: rgpio: use default pad config value for SCMI platform
If the platform uses SCMI pinctrl driver, pinctrl regitster can't accessed
by CPU Core directly, and currently SCMI pinctrl driver has no API to read
back the register value, so use default pad config value for GPIO pad
configuration, and in theory we could use a fixed pad config value in this
driver as each new GPIO configuration has no relation with previous
configuration.

Signed-off-by: Jiafei Pan <Jiafei.Pan@nxp.com>
2025-06-11 18:31:10 -07:00
Benjamin Cabé
1350918ac2 drivers: gpio: cc23x0: return negative error codes
fixed a couple occurrences of not returning -errno.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-06-09 14:51:17 -07:00
Phuc Pham
14ab7d8494 drivers: gpio: Add support for RZ/G2UL
Add GPIO support for RZ/G2UL

Signed-off-by: Phuc Pham <phuc.pham.xr@bp.renesas.com>
Signed-off-by: Nhut Nguyen <nhut.nguyen.kc@renesas.com>
2025-06-09 10:26:45 +01:00
Bjarki Arge Andreasen
d9cbd4ae1d drivers: gpio: smartbond: fix PM_DEVICE_DEFINE usage
The gpio_smartbond driver incorrectly uses the static
PM_DEVICE_DEFINE() and PM_DEVICE_GET() macros when creating a driver
instance from a devicetree instance number.

Update to use PM_DEVICE_DT_INST_DEFINE() and
PM_DEVICE_DT_INST_GET() macros.

Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
2025-06-06 11:52:50 +02:00
Tien Nguyen
5f69dd15a5 drivers: gpio: Add support for RZ/V2H
Add support for RZ/V2H

Signed-off-by: Tien Nguyen <tien.nguyen.zg@renesas.com>
Signed-off-by: Quang Le <quang.le.eb@bp.renesas.com>
2025-06-04 17:00:01 +02:00
Mike J. Chen
122b14bc68 drivers: gpio_mcux_lpc: fix bug configuring interrupts with GPIO_INT_WAKEUP
If GPIO_INT_WAKEUP is in the trig argument, the selection
of trigger mode breaks because the GPIO_INT_WAKEUP flag
breaks the equal comparisons.

Signed-off-by: Mike J. Chen <mjchen@google.com>
2025-06-04 08:46:15 +02:00
Stephan Gatzka
c4c1d92cee drivers: gpio: Use BIT(n) macro to define GPIO constants
This change would also solve that according to the C11 standard,
section 6.5, paragraph 4, the usage of bitwise operators on
signed integers is implementation defined.

Signed-off-by: Stephan Gatzka <stephan.gatzka@gmail.com>
2025-06-03 20:32:33 +02:00
Sreeram Tatapudi
33e5748a4f drivers: gpio: Update GPIO driver to support XMC7200
Update GPIO driver to support XMC7200

Signed-off-by: Sreeram Tatapudi <sreeram.praveen@infineon.com>
2025-05-28 21:29:20 +02:00
Ayush Singh
18c569829a drivers: gpio: davinci: Match GPIO address with Linux
Currently, the Zephyr dt requires address to the direction register
instead of the base GPIO address. usually means base address + 0x10 when
compared with Linux.

To make things more consistent between linux and zephyr, handle the
direction offset in the driver itself. This also lays the foundation for
supporting more than 32 GPIOs per port in the future by introducing
offsets for all the banks.

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-05-28 08:14:18 +02:00
Andrzej Głąbek
76e770de4b drivers: gpio_nrfx: Add missing break statements in gpio_pin_get_config
... so that the pull-up pin configuration can be correctly reported.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2025-05-26 13:17:01 +02:00
Amneesh Singh
8eb075fa7b drivers: gpio: davinci: fix gpio output
Currently to set/clear the pins, we do a logical OR of the value with the
existing values in set/clear registers. However, reading these registers
always returns the value in out_data register. This is undesirable as it
can cause unnecessary complications. Consider the following scenario:

We need to set PIN 0:
set_data |= BIT(0)

We need to clear PIN 1:
clr_data |= BIT(1)

The latter would also clear the 0th bit due to the aforementioned
behaviour.

This patch fixes this by writing the mask directly without ORing.

Signed-off-by: Amneesh Singh <a-singh7@ti.com>
2025-05-26 11:54:21 +02:00
Miguel Gazquez
2b91c467f2 modules: Update hal_wch
Update hal_wch.

As the hal upstream changed name, there is now a name conflict.
Rename ch32fun.h to hal_ch32fun.h to fix this conflict.

Signed-off-by: Miguel Gazquez <miguel.gazquez@bootlin.com>
2025-05-24 18:03:53 +02:00
Hao Luo
0e4ff0f3fe drivers: gpio: ambiq: need to select AMBIQ_HAL_USE_GPIO
This commit selects AMBIQ_HAL_USE_GPIO to include ambiq GPIO HAL

Signed-off-by: Hao Luo <hluo@ambiq.com>
2025-05-23 11:04:34 +02:00
Benson Huang
728a018f86 drivers: gpio: Fix GPIO initial status
The current procedure to initialize the GPIO is:
If the GPIO is configured as GPIO_OUTPUT and also has the
GPIO_OUTPUT_INIT_HIGH flag, set it to output high; otherwise, set it to
output low.

This may fail if the GPIO is simply configured as GPIO_OUTPUT without
specifying either INIT_HIGH or INIT_LOW, which means it is intended to
preserve the previous status. But in this case, we are currently setting it
to output low.

Fix this by explicitly initializing the GPIO to high or low according to
the configuration:
If the GPIO is configured as GPIO_OUTPUT and also with the
GPIO_OUTPUT_INIT_HIGH flag, set it to output high.
If the GPIO is configured as GPIO_OUTPUT and also with the
GPIO_OUTPUT_INIT_LOW flag, set it to output low.
If the GPIO is configured as GPIO_OUTPUT only,
do not set the output value.

Signed-off-by: Benson Huang <benson7633769@gmail.com>
2025-05-22 04:51:57 +02:00
Saravanan Sekar
dee5a06a45 drivers: gpio: mspm0: Add a gpio support for MSPM0 family
Add a GPIO driver support for TI MSPM0 SoC family.

Signed-off-by: Saravanan Sekar <saravanan@linumiz.com>
Signed-off-by: Jackson Farley <j-farley@ti.com>
2025-05-21 08:04:32 +02:00
Mahesh Mahadevan
b694af6576 drivers: gpio: Setup the pinctrl in the NXP LPC GPIO driver
The pinctrl register bits need to be restored to GPIO mode
after we exit from certain low power modes. We cannot rely
on the pin function to default to GPIO.

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2025-05-19 21:55:15 +02:00
Mirko Bottarelli
6a791bd478 drivers/gpio: Fix issue in gpio_pca6416
Added the possibility of leaving the gpio-int property empty, in case
the corresponding pin is not connected.

Signed-off-by: Mirko Bottarelli <mirko.bottarelli@gmail.com>
2025-05-19 16:49:07 +01:00
Mirko Bottarelli
28052aa7f0 drivers: gpio: Fix PCA6416 configuration
Fix device initialisation, allowing for empty interrupt_gpios in the
dts, as suggested by the documentation.

Signed-off-by: Mirko Bottarelli <mirko.bottarelli@gmail.com>
2025-05-19 16:49:07 +01:00
Bjarki Arge Andreasen
c4d475c1f2 drivers: gpio: nrfx: impl pm device runtime
Implement PM_DEVICE_RUNTIME for gpio_nrfx.c

PM is required to request/release the GPD domain if such exists
for a given GPIO instance. Without this, every single API call
will result in a requesting the GPD domain, which makes it slow
and unusable from ISRs, given GPD requires IPC. Now, user can
simply get the GPIO before using it, and put it once done,
calling the APIs from ISR while resumed.

Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
2025-05-14 15:19:22 +02:00
Ayush Singh
88b108d201 drivers: gpio: davinci: Allow empty pinctrl
Ignore error if default pinctrl missing. Some devices allow specifying
pinctrl in them, which is better to do , specially for static (on-board)
devices to keep overlays simpler.

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-05-14 09:11:52 +02:00
Chris Friedt
8409e425b3 drivers: gpio: pca series: dereference pointer in assignment
Properly dereference the value pointer in assignment.

```
In function 'gpio_pca_series_port_read_standard':
warning: assignment to 'gpio_port_value_t *' {aka 'unsigned int *'} \
  from 'uint32_t' {aka 'unsigned int'} makes pointer from integer   \
  without a cast [-Wint-conversion]
 1071 |                 value = sys_le32_to_cpu(input_data);
      |                       ^
```

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2025-05-13 22:20:10 -04:00
Ayush Singh
3124c7ad24 drivers: gpio: davinci: Fix for RAM MMIO
Move the direction reset to config init function. This ensures that regs
is read after the DEVICE_MMIO_NAMED_MAP is called, which is where the
init for RAM MMIO takes place

Tested on PocketBeagle 2 A53s.

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-05-13 22:19:51 -04:00
Lars Thiemann
03c557b004 drivers: gpio: pca-series: Cast pointer to void * in logging statements
This silences warnings created at runtime, as the %p format specifier
expects a void pointer.

Signed-off-by: Lars Thiemann <thiemann@cognid.de>
2025-05-10 13:02:12 +02:00
Lars Thiemann
13fe09c5b9 drivers: gpio: pca-series: Reset device before register access
Reset the port expander before accessing any register
or updating the cache.

Signed-off-by: Lars Thiemann <thiemann@cognid.de>
2025-05-10 13:02:12 +02:00
Bjarki Arge Andreasen
0826996337 drivers: gpio: gpio_nrfx: store init output val for get_config
The nRF GPIO hardware does not store the initial output value
set resulting from gpio_pin_configure() and thus, when
gpio_get_config() is used, the initial value is not returned.

This commit just reads the output value and sets the INIT
value to match in gpio_get_config().

Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
2025-05-09 12:55:45 +02:00
Nhut Nguyen
bc429da9fb drivers: gpio: rz: Mass renaming
Mass renaming is carried out to unify some prefixes and shorten some
macros, making the code easier to maintain and support new devices.

- Rename `int_dev` to `gpio_int_dev` for gpio interrupt
- Rename `eirq` to `ext_irq` for external interrupt
- Rename `gpio_rz_hw_config` to `gpio_rz_flags`
- Rename `p_pm` to `gpio_flags`
- Rename `pre_flags` to `rz_flags`
- Remove `_IOPORT` and `_PIN_CONFIGURE` in some macros
- Rename `GPIO_RZ_PIN_CONFIGURE_GET_FILTER`,
  `GPIO_RZ_PIN_CONFIGURE_GET`, `GPIO_RZ_PIN_SPECIAL_FLAG_GET` to
  `GPIO_RZ_FLAG_GET_FILTER`, `GPIO_RZ_FLAG_GET_CONFIG`,
  `GPIO_RZ_FLAG_GET_SPECIFIC` respectively

Signed-off-by: Nhut Nguyen <nhut.nguyen.kc@renesas.com>
2025-05-09 12:51:11 +02:00
Dhruv Menon
6b363634d8 drivers: gpio: update GPIO register addresses for TI davinci
This commit adds a padding of 0x10 bytes at the beginning of the
`gpio_davinci_regs` structure to correctly align the register
definitions with the actual register layout.

Previously, the DTS had to manually offset the base address by
0x10, introducing a special case in Zephyr's Davinci GPIO driver.
This change eliminates the need for that workaround
Adding the paddingi also help to maintain a similarly with also
to the linux counterpart.

Signed-off-by: Dhruv Menon <dhruvmenon1104@gmail.com>
2025-05-08 19:50:31 +02:00
Tim Lin
b4936c587a dts: ite: it51xxx: Change the base address of voltage selection
Change the base address of GPIO and pinctrl voltage selection
The new base address enables more pins to support voltage selection.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2025-05-07 13:33:14 +02:00
Robert Hancock
83488e4354 drivers: gpio: xlnx_ps: Do not clear GPIO states on initialization
This driver was setting all GPIO lines to input and the data register to
zero on initialization. This does not appear to be common practice among
other GPIO drivers, and in fact caused a serious problem on the ZynqMP
platform, where between 1 and 4 of the top-most GPIO lines are
frequently used by platform firmware and Vivado as reset lines for the
programmable logic. Since these resets are active low, and their
input/output state is ignored due to how they are connected to the EMIO
GPIO outputs from the PS, this caused the PL reset to be asserted when
the GPIO driver initialized, preventing any logic using that reset from
functioning properly.

There may also be other cases where GPIO line states have already been
set by the boot loader or firmware and clearing them may result in
improper behavior or glitches on the lines during initialization.

Update the driver to disable GPIO interrupts but leave the pin
modes/states unchanged until/unless they are explicitly reconfigured.

Signed-off-by: Robert Hancock <robert.hancock@calian.com>
2025-05-07 00:01:57 +02:00
Henrik Brix Andersen
0366df369b drivers: gpio: neorv32: add interrupt support
Add interrupt support to the NEORV32 GPIO controller driver.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2025-05-06 13:01:20 +02:00
Henrik Brix Andersen
3c8ac10dc7 drivers: gpio: neorv32: use spinlock instead of irq_lock()
Switch from using irq_lock()/irq_unlock() to using a k_spinlock.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2025-05-06 13:01:20 +02:00
Hank Wang
72509c385e drivers: gpio: sn74hc595: fix terminology for GPIO expander
The Kconfig help text for the SN74HC595 driver refers to the device
as a "GPIO extender", which is inconsistent with the devicetree
binding file (ti,sn74hc595.yaml) that describes it as a "GPIO expander".

Signed-off-by: Hank Wang <wanghanchi2000@gmail.com>
2025-05-06 12:00:31 +02:00
McAtee Maxwell
e6c5e26597 drivers: allow disabling gpio interrupt in ifx-cat1 gpio driver
- allow GPIO_INT_MODE_DISABLED in interrupt_configure function

Signed-off-by: McAtee Maxwell <maxwell.mcatee@infineon.com>
2025-05-02 10:39:45 +02:00
Duy Nguyen
86024ffebb drivers: gpio: Support GPIO driver for Renesas RX MCU
Initial commit for GPIO driver support on board using RX130 MCUs
* drivers: GPIO: implementation for GPIO driver on RSK_RX130_512KB
* dts: rx: add device node for GPIO of RSK_RX130_512KB

Signed-off-by: Duy Nguyen <duy.nguyen.xa@renesas.com>
Signed-off-by: Phi Tran <phi.tran.jg@bp.renesas.com>
2025-05-02 09:18:16 +02:00