Commit graph

1572 commits

Author SHA1 Message Date
Daniel DeGrasse
36cc74e7e8 drivers: gpio: gpio_mcux_lpc: add support for module interrupts
On iMX.RT devices, the number of GPIO pins exceeds the maximum of
64 that the PINT interrupt controller can support. Therefore, two
interrupt lines are now shared between the GPIO modules.

This patch allows the user to set the interrupt source for a GPIO
peripheral. For most LPC devices, this will always be the PINT. For some
RT devices, the PINT cannot use pins on GPIO modules other than 0 and 1
as input, and thus the INTA and INTB sources should be used.

Since Zephyr does not support sharing these interrupt between all GPIO
controllers, the user must configure a subset of all GPIO controllers to
use the shared module interrupts. An example of how to do so is provided
for the RT595 EVK.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2023-04-18 16:14:57 -05:00
Daniel DeGrasse
b8a99a27cc drivers: gpio: gpio_mcux_lpc: remove PINT code
Remove PINT management code from the LPC GPIO driver, as this code is
now contained within the PINT interrupt controller driver, which exposes
an interface to install interrupt callbacks.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2023-04-18 16:14:57 -05:00
Andy Sinclair
0d68c86c95 drivers: gpio: npm1300: Initial driver for nPM1300 PMIC
Initial GPIO driver for NPM1300 PMIC

Signed-off-by: Andy Sinclair <andy.sinclair@nordicsemi.no>
2023-04-17 10:14:40 +02:00
Gerard Marull-Paretas
a5fd0d184a init: remove the need for a dummy device pointer in SYS_INIT functions
The init infrastructure, found in `init.h`, is currently used by:

- `SYS_INIT`: to call functions before `main`
- `DEVICE_*`: to initialize devices

They are all sorted according to an initialization level + a priority.
`SYS_INIT` calls are really orthogonal to devices, however, the required
function signature requires a `const struct device *dev` as a first
argument. The only reason for that is because the same init machinery is
used by devices, so we have something like:

```c
struct init_entry {
	int (*init)(const struct device *dev);
	/* only set by DEVICE_*, otherwise NULL */
	const struct device *dev;
}
```

As a result, we end up with such weird/ugly pattern:

```c
static int my_init(const struct device *dev)
{
	/* always NULL! add ARG_UNUSED to avoid compiler warning */
	ARG_UNUSED(dev);
	...
}
```

This is really a result of poor internals isolation. This patch proposes
a to make init entries more flexible so that they can accept sytem
initialization calls like this:

```c
static int my_init(void)
{
	...
}
```

This is achieved using a union:

```c
union init_function {
	/* for SYS_INIT, used when init_entry.dev == NULL */
	int (*sys)(void);
	/* for DEVICE*, used when init_entry.dev != NULL */
	int (*dev)(const struct device *dev);
};

struct init_entry {
	/* stores init function (either for SYS_INIT or DEVICE*)
	union init_function init_fn;
	/* stores device pointer for DEVICE*, NULL for SYS_INIT. Allows
	 * to know which union entry to call.
	 */
	const struct device *dev;
}
```

This solution **does not increase ROM usage**, and allows to offer clean
public APIs for both SYS_INIT and DEVICE*. Note that however, init
machinery keeps a coupling with devices.

**NOTE**: This is a breaking change! All `SYS_INIT` functions will need
to be converted to the new signature. See the script offered in the
following commit.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

init: convert SYS_INIT functions to the new signature

Conversion scripted using scripts/utils/migrate_sys_init.py.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

manifest: update projects for SYS_INIT changes

Update modules with updated SYS_INIT calls:

- hal_ti
- lvgl
- sof
- TraceRecorderSource

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

tests: devicetree: devices: adjust test

Adjust test according to the recently introduced SYS_INIT
infrastructure.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>

tests: kernel: threads: adjust SYS_INIT call

Adjust to the new signature: int (*init_fn)(void);

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-12 14:28:07 +00:00
Mahesh Mahadevan
174824f1cb drivers: gpio: Update NXP GPIO driver for the updated IP Block
1. Move the GPIO mux setting to the soc layer. The GPIO MUX
value may vary based on the SoC Family
2. Enable the digital input buffer if available

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2023-04-06 14:14:11 -05:00
Sung-Chi Li
532bd562fa drivers: gpio: numicro: Implement enable/disable pin interrupt
Implement the GPIO_INT_MODE_ENABLE_ONLY and GPIO_INT_MODE_DISABLE_ONLY
on numicro GPIO driver.

Signed-off-by: Sung-Chi Li <lschyi@google.com>
2023-04-06 11:44:07 -04:00
Sung-Chi Li
db379eee6f driver: gpio: npcx: Implement enable/disable pin interrupt
Implement the GPIO_INT_MODE_ENABLE_ONLY and GPIO_INT_MODE_DISABLE_ONLY
on npcx GPIO driver.

Signed-off-by: Sung-Chi Li <lschyi@google.com>
2023-04-06 11:44:07 -04:00
Sung-Chi Li
ab77ce0cb8 drivers: gpio: stm32: Implement enable/disable pin interrupt
Implement the GPIO_INT_MODE_ENABLE_ONLY and GPIO_INT_MODE_DISABLE_ONLY
on stm32 GPIO driver.

Signed-off-by: Sung-Chi Li <lschyi@google.com>
2023-04-06 11:44:07 -04:00
Sung-Chi Li
1f7b0c440d drivers: gpio: it8xxx2: Implement enable/disable pin interrupt
Implement the GPIO_INT_MODE_ENABLE_ONLY and GPIO_INT_MODE_DISABLE_ONLY
on it8xxx2 gpio driver.

Signed-off-by: Sung-Chi Li <lschyi@google.com>
2023-04-06 11:44:07 -04:00
Sung-Chi Li
21b2d3aa63 drivers: gpio: Implement pin interrupt enable and disable
Implement the driver method pin_interrupt_enable and pin_interrupt_disable.
This commit fixes getting the get_pending_int by updating the interrupts
field in the gpio_emul_data filed when interrupt is triggered. Also,
introduces a new filed enabled_interrupts to better simulate the
behavior of the interrupt pending and whether the interrupt is
enabled/disabled.

Signed-off-by: Sung-Chi Li <lschyi@google.com>
2023-04-06 11:44:07 -04:00
Sung-Chi Li
b78208960d drivers: gpio: Add APIs for enabling/disabling interrupt
Add pin_interrupt_enable and pin_interrupt_disable in gpio_driver_api,
and add corresponding APIs in gpio.h for application to enable/disable
an interrupt without reconfiguring again.
This CL also Create a new Kconfig option for this feature.

Signed-off-by: Sung-Chi Li <lschyi@google.com>
2023-04-06 11:44:07 -04:00
Pieter De Gendt
6b532ff43e treewide: Update clock control API usage
Replace all (clock_control_subsys_t *) casts with (clock_control_subsys_t)

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-04-05 10:55:46 +02:00
Pawel Czarnecki
a56ca2df97 drivers: gpio: gecko: add support for efr32xg24
Add defined() check for EFR32MG24

Signed-off-by: Pawel Czarnecki <pczarnecki@antmicro.com>
2023-04-04 13:34:45 +02:00
Pieter De Gendt
cd6fe580b0 drivers: gpio: Add NXP SC18IM704 GPIO support
Implement external GPIO controller driver with NXP's SC18IM704 device.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-04-03 20:02:51 +02:00
Kumar Gala
d82175eadd gpio: fix armclang compiler warnings with is*() functions
We get compile warnings of the form:

error: converting the result of
'<<' to a boolean; did you mean
'((__aeabi_ctype_table_ + 1)[(byte)] << 28) != 0'?
 [-Werror,-Wint-in-bool-context]
                if (!isprint(byte)) {
                     ^

Since isprint (and the other is* functions) return an int, change check
to an explicit test against the return value.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-04-01 12:31:58 -04:00
Henrik Brix Andersen
c41dd36de2 drivers: kconfig: unify menuconfig title strings
Unify the drivers/*/Kconfig menuconfig title strings to the format
"<class> [(acronym)] [bus] drivers".

Including both the full name of the driver class and an acronym makes
menuconfig more user friendly as some of the acronyms are less well-known
than others. It also improves Kconfig search, both via menuconfig and via
the generated Kconfig documentation.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-03-28 15:06:06 +02:00
Henrik Brix Andersen
e440b023dd drivers: gpio: test: use CONFIG_GPIO_INIT_PRIORITY for init priority
Use the dedicated CONFIG_GPIO_INIT_PRIORITY for vnd,gpio test driver
initialization priority.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-03-27 13:20:03 +00:00
Henrik Brix Andersen
2c5d7d78dd drivers: gpio: test: add driver config and data structs
Add config and data structs to the vnd,gpio test driver as these are
required by the GPIO API.

Fixes: #55884

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-03-27 13:20:03 +00:00
Benedikt Schmidt
1009b9152a drivers: gpio: remove doxygen comments in MCP23S17 driver
Remove the doxygen comments in the driver
for the MCP23S17.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2023-03-24 09:22:32 +01:00
Benedikt Schmidt
a8b2ff88de drivers: gpio: remove not required header
Move the content of the header for the MCP23S17
into the source file.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2023-03-24 09:22:32 +01:00
Gerson Fernando Budke
c77c1cc197 drivers: gpio: sam: Update to use clock control
This update Atmel SAM gpio and pinctrl drivers to use clock control
drivers.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2023-03-21 14:12:25 -07:00
Marc Desvaux
0548584d4d drivers: gpio/exti: stm32: Use st,stm32g0-exti compatible
remove all #ifdef CONFIG_SOC_SERIES_STM32xx
before to add a st,stm32g0-exti compatible
added to the matching targets:
C0/G0/U5/L5/MP1:

Signed-off-by: Marc Desvaux <marc.desvaux-ext@st.com>
2023-03-21 09:37:30 +01:00
Armin Brauns
01e8b3445e drivers: gpio: mcp23xxx: add support for reset pin
This allows the device to be reset to a known state before initialization.

Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
2023-03-20 10:43:12 +01:00
Armin Brauns
07af23c1c6 drivers: gpio: mcp23xxx: support single-edge interrupts
An interrupt is triggered for every edge, but only the desired edges cause
a callback to be called.

Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
2023-03-20 10:43:12 +01:00
Armin Brauns
0db9785892 drivers: gpio: mcp23xxx: support pin interrupts
No single-edge interrupts for now, since they are not supported in
hardware.

Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
2023-03-20 10:43:12 +01:00
Armin Brauns
1a566e6a7f drivers: gpio: mcp23xxx: fix typo
Should be the Output LATch register. "IK" is one key away from "OL" on
QWERTY keyboards.

This define wasn't actually used anywhere.

Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
2023-03-20 10:43:12 +01:00
Fabio Baltieri
2815f96440 drivers: move gpio_keys from gpio to input
Port the gpio_keys_zephyr driver from the gpio subsystem with a
dedicated API to the input subsystem reporting input events.

Move the test as well, simplify the cases a bit since the API is simpler
now.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-03-14 17:15:09 -04:00
Benjamin Björnsson
cc03cb3790 drivers: gpio: gpio_stm32: Add STM32C0 Support
Add STM32C0 support to gpio driver.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2023-03-14 17:35:37 +00:00
Manojkumar Subramaniam
f75c5b8c3b drivers: gpio: sifive: Update to use the available common IRQ API and
remove obsolete code.

Fixes issue: #20338

Signed-off-by: Manojkumar Subramaniam <manoj@electrolance.com>
2023-03-10 07:59:42 -06:00
Nazar Palamar
bc638f38db drivers: gpio: Add Infineon CAT1 GPIO driver
Added initial version of Infineon CAT1 GPIO driver.
Added initial version of binding file for Infineon CAT1 GPIO driver.

Signed-off-by: Nazar Palamar <nazar.palamar@infineon.com>
2023-03-01 11:44:57 +01:00
Benedikt Schmidt
ecafade8ae drivers: gpio: add driver for PCAL6416A
Generalize the driver for PCAL6408A into a more abstract base
and reuse this abstraction to implement a driver for
PCAL6416A.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2023-02-28 20:09:19 -05:00
Benedikt Schmidt
fd44b2eb2d drivers: gpio: add driver for BD8LB600FS
Add a driver for BD8LB600FS

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2023-02-27 06:44:23 -05:00
Lucas Tamborrino
1eda399c44 drivers: gpio: esp32: fix reset interrupt status on new config
The interrupt status of the GPIO was not cleared when a new
interrupt configuration was set. This prevents the driver from
passsing all the gpio tests.

Fixes #54833

Signed-off-by: Lucas Tamborrino <lucas.tamborrino@espressif.com>
2023-02-27 11:35:26 +01:00
Purdea Andrei
38f554ef4f drivers: gpio_rpi_pico.c: add support for single-ended IO
Note: RP2040 can support single-ended IO, by setting the GPIO_OUT
register to a constant value, and then changing the GPIO_OE register
instead, when the output has to change. To do this, the output-setting
functions need to know which pins have been configured as single-ended,
and for that reason the data structure has been extended to include
this information.

Another change is the PR, is that setting of the pull-ups/pull-downs
now applies to both inputs and outputs as well. Previous solution was
wrong, because if the user wanted to set up an input with a pull
resistor enabled, and then reconfigure it to an output without any
pulls, then the pulls remained in place for the output. Now pulls
are correctly set based on the gpio flags for outputs too, and this
is especially useful for single-ended outputs too.

Signed-off-by: Purdea Andrei <andrei@purdea.ro>
2023-02-26 18:38:08 -05:00
Gerard Marull-Paretas
d925c660ed drivers: pinmux: stm32: drop driver
Drop STM32 pinmux driver in favor of pinctrl. Some definitions located
in pinmux headers were used by the pinctrl driver, so they have been
moved there.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-02-23 16:56:04 -05:00
Alexander Wachter
244f623f8c drivers: gpio: emul: replace mutex with spinlock
Replace all mutex with spinlocks to make the driver usable
from ISRs.

Signed-off-by: Alexander Wachter <alexander@wachter.cloud>
2023-02-22 21:48:30 +01:00
Dino Li
e442a15c32 gpio/it8xxx2: do not set flag if register does not exist
Since not all GPIOs support voltage selection, voltage flag
is only set if voltage selection register is present.

fixes: #54366

Signed-off-by: Dino Li <Dino.Li@ite.com.tw>
2023-02-11 08:20:40 +09:00
Siyuan Cheng
1a5676d338 ARC: boards: hsdk: fix cy8c95xx I2C GPIO port init
cy8c95xx I2C GPIO support was broken in commit 4b30008 due
to wrong i2c bus and addr were wrote during GPIO_PORT_INIT.
Now fix this issue.

Signed-off-by: Siyuan Cheng <siyuanc@synopsys.com>
2023-02-10 10:19:19 +01:00
Fabio Baltieri
47874e2f6e gpio: gpio_keys_zephyr: drop one instance of num_keys
The driver currently stores num_keys in both config and data. Drop the
data copy, save 4 bytes of RAM.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-02-06 10:06:36 +01:00
Fabio Baltieri
5d9c65fe7f gpio: gpio_keys_zephyr: add missing gpio initialization
The driver is missing the GPIO initialization entirely, meaning that
flags like PULL_UP are not currently being applied. Add the missing
call.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-02-01 09:25:40 +00:00
Fabio Baltieri
48a6f160f2 gpio: gpio_keys_zephyr: fix build warning with assertion disables
Fix two "unused variable" warnings when compiling with assertions
disabled. The two variables are used only in the __ASSERT() call.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-01-31 06:08:02 -05:00
Siyuan Cheng
59130b11dc driver: gpio: Add pin_configure api for creg_gpio driver
Update pin_configure api for creg_gpio driver

Signed-off-by: Siyuan Cheng <siyuanc@synopsys.com>
2023-01-27 19:52:25 -05:00
Henrik Brix Andersen
cb274e6a3c drivers: gpio: add GPIO hog support
Add support for automatically configuring GPIO hogs defined in the
devicetree during system initialization.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-01-27 14:38:52 -08:00
Andrei Emeltchenko
63f360c7fc drivers: gpio_nct38xx_port: Fix checking wrong return
Fix error check for previous function return code.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-01-21 21:27:38 -05:00
Ruibin Chang
d7f482a022 ITE driver/gpio/it8xxx2: add kscan pins gpio driver
Add kscan pins gpio driver for KSI[7:0], KSO[15:0] pins that
they can be configured to gpio mode. These pins registers address,
bit fields and function are different from GPIO group, so I create
a new compatible driver for these pins.

Signed-off-by: Ruibin Chang <Ruibin.Chang@ite.com.tw>
2023-01-14 09:22:39 +01:00
Manuel Arguelles
492e196e8a drivers: gpio: rename S32 to NXP S32
Following updates previously done for other drivers, rename all
occurrences of S32 to NXP S32 to avoid ambiguity.

Signed-off-by: Manuel Arguelles <manuel.arguelles@nxp.com>
2023-01-04 16:51:38 +01:00
Al Semjonovs
211e4d276e gpio: Add driver support for software based gpio debounce
Software based GPIO debounce driver implementation.

Signed-off-by: Al Semjonovs <asemjonovs@google.com>
2023-01-04 10:36:00 +01:00
Antonio Tessarolo
e614a38cbd nxp/imx: fix imx6sx gpio pull up-down configuration
To enable pin pull up/down with the new pinmux APIs bit 13 must be set.

Signed-off-by: Antonio Tessarolo <anthonytexdev@gmail.com>
2023-01-03 10:46:52 -06:00
Gerard Marull-Paretas
4d9b6c4e2e drivers: gpio: sx1509b: add multi-instance support
The driver only supported one instance. Update it to support multiple
instances.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-12-28 18:47:25 +01:00
Daniel DeGrasse
21c4957cde drivers: gpio: fix gpio-reserved-ranges handling in MCUX iGPIO driver
Fix handling of gpio-reserved-ranges within MCUX iGPIO driver, to ensure
that the configuration IDX will be correctly calculated for pins where
multiple reserved ranges are present on the GPIO controller

Fixes #52506

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-12-22 11:05:52 +01:00