zephyr/drivers/gpio
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
..
CMakeLists.txt drivers: gpio: Add NXP SC18IM704 GPIO support 2023-04-03 20:02:51 +02:00
gpio_andes_atcgpio100.c drivers: gpio: expose gpio_utils.h to external GPIO drivers 2022-10-27 15:38:51 +02:00
gpio_b91.c drivers: gpio: expose gpio_utils.h to external GPIO drivers 2022-10-27 15:38:51 +02:00
gpio_bd8lb600fs.c drivers: gpio: add driver for BD8LB600FS 2023-02-27 06:44:23 -05:00
gpio_cc13xx_cc26xx.c drivers: gpio: expose gpio_utils.h to external GPIO drivers 2022-10-27 15:38:51 +02:00
gpio_cc32xx.c drivers: gpio: expose gpio_utils.h to external GPIO drivers 2022-10-27 15:38:51 +02:00
gpio_cmsdk_ahb.c treewide: Update clock control API usage 2023-04-05 10:55:46 +02:00
gpio_creg_gpio.c driver: gpio: Add pin_configure api for creg_gpio driver 2023-01-27 19:52:25 -05:00
gpio_cy8c95xx.c ARC: boards: hsdk: fix cy8c95xx I2C GPIO port init 2023-02-10 10:19:19 +01:00
gpio_dw_registers.h
gpio_dw.c driver: dw: Use base_addr variable to set dir. 2022-12-11 20:37:33 -05:00
gpio_dw.h drivers: gpio: dw: Remove dead clock gate code 2022-07-14 10:31:42 +02:00
gpio_emul_sdl.c include: add missing kernel.h include 2022-10-11 18:05:17 +02:00
gpio_emul.c drivers: gpio: Implement pin interrupt enable and disable 2023-04-06 11:44:07 -04:00
gpio_eos_s3.c drivers: gpio: expose gpio_utils.h to external GPIO drivers 2022-10-27 15:38:51 +02:00
gpio_esp32.c drivers: gpio: esp32: fix reset interrupt status on new config 2023-02-27 11:35:26 +01:00
gpio_fxl6408.c drivers: gpio: expose gpio_utils.h to external GPIO drivers 2022-10-27 15:38:51 +02:00
gpio_gd32.c treewide: Update clock control API usage 2023-04-05 10:55:46 +02:00
gpio_gecko.c drivers: gpio: gecko: add support for efr32xg24 2023-04-04 13:34:45 +02:00
gpio_handlers.c gpio: add function to get current configuration 2022-07-12 19:19:09 +02:00
gpio_hogs.c init: remove the need for a dummy device pointer in SYS_INIT functions 2023-04-12 14:28:07 +00:00
gpio_ifx_cat1.c drivers: gpio: Add Infineon CAT1 GPIO driver 2023-03-01 11:44:57 +01:00
gpio_imx.c nxp/imx: fix imx6sx gpio pull up-down configuration 2023-01-03 10:46:52 -06:00
gpio_intel.c drivers: gpio: expose gpio_utils.h to external GPIO drivers 2022-10-27 15:38:51 +02:00
gpio_ite_it8xxx2.c init: remove the need for a dummy device pointer in SYS_INIT functions 2023-04-12 14:28:07 +00:00
gpio_kscan_ite_it8xxx2.c ITE driver/gpio/it8xxx2: add kscan pins gpio driver 2023-01-14 09:22:39 +01:00
gpio_litex.c drivers: gpio: expose gpio_utils.h to external GPIO drivers 2022-10-27 15:38:51 +02:00
gpio_lmp90xxx.c drivers: gpio: expose gpio_utils.h to external GPIO drivers 2022-10-27 15:38:51 +02:00
gpio_lpc11u6x.c drivers: gpio: expose gpio_utils.h to external GPIO drivers 2022-10-27 15:38:51 +02:00
gpio_mchp_mss.c drivers: gpio: expose gpio_utils.h to external GPIO drivers 2022-10-27 15:38:51 +02:00
gpio_mchp_xec_v2.c drivers: gpio: expose gpio_utils.h to external GPIO drivers 2022-10-27 15:38:51 +02:00
gpio_mchp_xec.c drivers: gpio: expose gpio_utils.h to external GPIO drivers 2022-10-27 15:38:51 +02:00
gpio_mcp23s17.c drivers: gpio: remove doxygen comments in MCP23S17 driver 2023-03-24 09:22:32 +01:00
gpio_mcp23sxx.c drivers: gpio: mcp23xxx: add support for reset pin 2023-03-20 10:43:12 +01:00
gpio_mcp23xxx.c drivers: gpio: mcp23xxx: add support for reset pin 2023-03-20 10:43:12 +01:00
gpio_mcp23xxx.h drivers: gpio: mcp23xxx: add support for reset pin 2023-03-20 10:43:12 +01:00
gpio_mcp230xx.c drivers: gpio: mcp23xxx: add support for reset pin 2023-03-20 10:43:12 +01:00
gpio_mcux_igpio.c drivers: gpio: fix gpio-reserved-ranges handling in MCUX iGPIO driver 2022-12-22 11:05:52 +01:00
gpio_mcux_lpc.c drivers: gpio: gpio_mcux_lpc: Use arbitrary amount of IRQ 2022-11-02 10:34:00 +01:00
gpio_mcux.c drivers: gpio: Update NXP GPIO driver for the updated IP Block 2023-04-06 14:14:11 -05:00
gpio_mmio32.c include: add missing irq.h include 2022-10-11 18:05:17 +02:00
gpio_nct38xx_alert.c drivers: add mising braces to single line if statements 2022-07-06 11:00:45 -04:00
gpio_nct38xx_port.c drivers: gpio_nct38xx_port: Fix checking wrong return 2023-01-21 21:27:38 -05:00
gpio_nct38xx.c drivers: gpio: nct38xx: use DT_INST_FOREACH_CHILD_STATUS_OKAY_SEP 2022-08-30 16:19:57 +02:00
gpio_nct38xx.h
gpio_neorv32.c drivers: gpio: expose gpio_utils.h to external GPIO drivers 2022-10-27 15:38:51 +02:00
gpio_npcx.c driver: gpio: npcx: Implement enable/disable pin interrupt 2023-04-06 11:44:07 -04:00
gpio_npm6001.c drivers: gpio: npm6001: initial driver 2022-11-22 11:05:19 +01:00
gpio_nrfx.c drivers: gpio: expose gpio_utils.h to external GPIO drivers 2022-10-27 15:38:51 +02:00
gpio_numicro.c drivers: gpio: numicro: Implement enable/disable pin interrupt 2023-04-06 11:44:07 -04:00
gpio_nxp_s32.c drivers: gpio: rename S32 to NXP S32 2023-01-04 16:51:38 +01:00
gpio_pca95xx.c drivers: gpio: expose gpio_utils.h to external GPIO drivers 2022-10-27 15:38:51 +02:00
gpio_pca953x.c drivers: gpio: expose gpio_utils.h to external GPIO drivers 2022-10-27 15:38:51 +02:00
gpio_pcal64xxa.c drivers: gpio: add driver for PCAL6416A 2023-02-28 20:09:19 -05:00
gpio_pcf8574.c drivers: gpio: expose gpio_utils.h to external GPIO drivers 2022-10-27 15:38:51 +02:00
gpio_psoc6.c drivers: gpio: expose gpio_utils.h to external GPIO drivers 2022-10-27 15:38:51 +02:00
gpio_rcar.c treewide: Update clock control API usage 2023-04-05 10:55:46 +02:00
gpio_rpi_pico.c drivers: gpio_rpi_pico.c: add support for single-ended IO 2023-02-26 18:38:08 -05:00
gpio_rt1718s_port.c driver: gpio: rt1718s: Add RT1718S GPIO driver 2022-11-28 10:48:53 +01:00
gpio_rt1718s.c driver: gpio: rt1718s: Add RT1718S GPIO driver 2022-11-28 10:48:53 +01:00
gpio_rt1718s.h driver: gpio: rt1718s: Add RT1718S GPIO driver 2022-11-28 10:48:53 +01:00
gpio_rv32m1.c drivers: gpio: expose gpio_utils.h to external GPIO drivers 2022-10-27 15:38:51 +02:00
gpio_sam0.c drivers: gpio: expose gpio_utils.h to external GPIO drivers 2022-10-27 15:38:51 +02:00
gpio_sam4l.c treewide: Update clock control API usage 2023-04-05 10:55:46 +02:00
gpio_sam.c treewide: Update clock control API usage 2023-04-05 10:55:46 +02:00
gpio_sc18im704.c drivers: gpio: Add NXP SC18IM704 GPIO support 2023-04-03 20:02:51 +02:00
gpio_shell.c gpio: fix armclang compiler warnings with is*() functions 2023-04-01 12:31:58 -04:00
gpio_sifive.c drivers: gpio: sifive: Update to use the available common IRQ API and 2023-03-10 07:59:42 -06:00
gpio_smartbond.c drivers: gpio: expose gpio_utils.h to external GPIO drivers 2022-10-27 15:38:51 +02:00
gpio_sn74hc595.c drivers: tests: replace usage of spi_is_ready with spi_is_ready_dt 2022-12-07 09:40:23 -06:00
gpio_stellaris.c drivers: gpio: expose gpio_utils.h to external GPIO drivers 2022-10-27 15:38:51 +02:00
gpio_stm32.c drivers: gpio: stm32: Implement enable/disable pin interrupt 2023-04-06 11:44:07 -04:00
gpio_stm32.h drivers: pinmux: stm32: drop driver 2023-02-23 16:56:04 -05:00
gpio_stmpe1600.c drivers: gpio: expose gpio_utils.h to external GPIO drivers 2022-10-27 15:38:51 +02:00
gpio_sx1509b.c drivers: gpio: sx1509b: add multi-instance support 2022-12-28 18:47:25 +01:00
gpio_tca6424a.c drivers: gpio: Add TCA6424A driver 2022-11-18 10:10:11 +01:00
gpio_test.c drivers: gpio: test: use CONFIG_GPIO_INIT_PRIORITY for init priority 2023-03-27 13:20:03 +00:00
gpio_xlnx_axi.c drivers: gpio: expose gpio_utils.h to external GPIO drivers 2022-10-27 15:38:51 +02:00
gpio_xlnx_ps_bank.c drivers: gpio: expose gpio_utils.h to external GPIO drivers 2022-10-27 15:38:51 +02:00
gpio_xlnx_ps_bank.h
gpio_xlnx_ps.c drivers: gpio: expose gpio_utils.h to external GPIO drivers 2022-10-27 15:38:51 +02:00
gpio_xlnx_ps.h drivers: gpio: xlnx_ps: Fix compiler warning 2022-08-20 11:32:37 -05:00
gpio_xmc4xxx.c drivers: gpio_xmc4xxx: Use interrupt controller for edge/level interrupts 2022-12-12 10:51:29 +01:00
Kconfig drivers: gpio: Add APIs for enabling/disabling interrupt 2023-04-06 11:44:07 -04:00
Kconfig.andes_atcgpio100 drivers: gpio: Update drivers to use devicetree Kconfig symbol 2022-07-23 09:26:09 -05:00
Kconfig.b91 drivers: gpio: Update drivers to use devicetree Kconfig symbol 2022-07-23 09:26:09 -05:00
Kconfig.bd8lb600fs drivers: gpio: add driver for BD8LB600FS 2023-02-27 06:44:23 -05:00
Kconfig.cc13xx_cc26xx drivers: gpio: Update drivers to use devicetree Kconfig symbol 2022-07-23 09:26:09 -05:00
Kconfig.cc32xx drivers: gpio: Update drivers to use devicetree Kconfig symbol 2022-07-23 09:26:09 -05:00
Kconfig.cmsdk_ahb drivers: gpio: Update drivers to use devicetree Kconfig symbol 2022-07-23 09:26:09 -05:00
Kconfig.creg_gpio drivers: gpio: Update drivers to use devicetree Kconfig symbol 2022-07-23 09:26:09 -05:00
Kconfig.cy8c95xx drivers: gpio: Update drivers to use devicetree Kconfig symbol 2022-07-23 09:26:09 -05:00
Kconfig.dw drivers: gpio: Update drivers to use devicetree Kconfig symbol 2022-07-23 09:26:09 -05:00
Kconfig.emul drivers: gpio: Update drivers to use devicetree Kconfig symbol 2022-07-23 09:26:09 -05:00
Kconfig.emul_sdl drivers: gpio: Add SDL emulated GPIO support 2022-10-03 10:12:03 +02:00
Kconfig.eos_s3 drivers: gpio: Update drivers to use devicetree Kconfig symbol 2022-07-23 09:26:09 -05:00
Kconfig.esp32 drivers: gpio: Update drivers to use devicetree Kconfig symbol 2022-07-23 09:26:09 -05:00
Kconfig.fxl6408 drivers: gpio: Update drivers to use devicetree Kconfig symbol 2022-07-23 09:26:09 -05:00
Kconfig.gd32 drivers: gpio: gd32: add dependency on the EXTI 2022-11-09 06:26:41 -05:00
Kconfig.gecko drivers: gpio: Update drivers to use devicetree Kconfig symbol 2022-07-23 09:26:09 -05:00
Kconfig.ifx_cat1 drivers: gpio: Add Infineon CAT1 GPIO driver 2023-03-01 11:44:57 +01:00
Kconfig.imx drivers: gpio: Update drivers to use devicetree Kconfig symbol 2022-07-23 09:26:09 -05:00
Kconfig.intel drivers: gpio: Update drivers to use devicetree Kconfig symbol 2022-07-23 09:26:09 -05:00
Kconfig.it8xxx2 ITE driver/gpio/it8xxx2: add kscan pins gpio driver 2023-01-14 09:22:39 +01:00
Kconfig.litex drivers: gpio: Update drivers to use devicetree Kconfig symbol 2022-07-23 09:26:09 -05:00
Kconfig.lmp90xxx drivers: gpio: Update drivers to use devicetree Kconfig symbol 2022-07-23 09:26:09 -05:00
Kconfig.lpc11u6x drivers: gpio: remove pinmux dependency in lpc11u6x Kconfig 2022-10-11 08:25:46 -05:00
Kconfig.mchp_mss drivers: gpio: add Microchip PolarFire SoC GPIO driver 2022-08-01 10:29:21 +02:00
Kconfig.mcp23s17 drivers: gpio: Update drivers to use devicetree Kconfig symbol 2022-07-23 09:26:09 -05:00
Kconfig.mcp23xxx drivers: gpio: Update drivers to use devicetree Kconfig symbol 2022-07-23 09:26:09 -05:00
Kconfig.mcux drivers: gpio: Update drivers to use devicetree Kconfig symbol 2022-07-23 09:26:09 -05:00
Kconfig.mcux_igpio drivers: gpio: Update drivers to use devicetree Kconfig symbol 2022-07-23 09:26:09 -05:00
Kconfig.mcux_lpc drivers: gpio: Update drivers to use devicetree Kconfig symbol 2022-07-23 09:26:09 -05:00
Kconfig.mmio32
Kconfig.nct38xx drivers: gpio: Update drivers to use devicetree Kconfig symbol 2022-07-23 09:26:09 -05:00
Kconfig.neorv32 drivers: gpio: Update drivers to use devicetree Kconfig symbol 2022-07-23 09:26:09 -05:00
Kconfig.npcx drivers: gpio: Update drivers to use devicetree Kconfig symbol 2022-07-23 09:26:09 -05:00
Kconfig.npm6001 drivers: gpio: npm6001: initial driver 2022-11-22 11:05:19 +01:00
Kconfig.nrfx drivers: gpio: Update drivers to use devicetree Kconfig symbol 2022-07-23 09:26:09 -05:00
Kconfig.numicro drivers: gpio: add driver for nuvoton numicro 2022-12-08 18:46:33 +01:00
Kconfig.nxp_s32 drivers: gpio: rename S32 to NXP S32 2023-01-04 16:51:38 +01:00
Kconfig.pca95xx drivers: gpio: Update drivers to use devicetree Kconfig symbol 2022-07-23 09:26:09 -05:00
Kconfig.pca953x drivers: gpio: pca953x: select I2C 2022-10-03 10:12:03 +02:00
Kconfig.pcal64xxa drivers: gpio: add driver for PCAL6416A 2023-02-28 20:09:19 -05:00
Kconfig.pcf8574 drivers: gpio: Add driver for pcf8574 2022-10-03 13:56:32 +02:00
Kconfig.psoc6 drivers: gpio: Update drivers to use devicetree Kconfig symbol 2022-07-23 09:26:09 -05:00
Kconfig.rcar drivers: gpio: Update drivers to use devicetree Kconfig symbol 2022-07-23 09:26:09 -05:00
Kconfig.rpi_pico drivers: gpio: Update drivers to use devicetree Kconfig symbol 2022-07-23 09:26:09 -05:00
Kconfig.rt1718s driver: gpio: rt1718s: Add RT1718S GPIO driver 2022-11-28 10:48:53 +01:00
Kconfig.rv32m1 drivers: gpio: Update drivers to use devicetree Kconfig symbol 2022-07-23 09:26:09 -05:00
Kconfig.sam drivers: gpio: sam: Fix Kconfig default for SAM4L 2022-07-26 08:49:38 +02:00
Kconfig.sam0 drivers: gpio: Update drivers to use devicetree Kconfig symbol 2022-07-23 09:26:09 -05:00
Kconfig.sc18im704 drivers: gpio: Add NXP SC18IM704 GPIO support 2023-04-03 20:02:51 +02:00
Kconfig.sifive drivers: gpio: Update drivers to use devicetree Kconfig symbol 2022-07-23 09:26:09 -05:00
Kconfig.smartbond drivers: gpio: Add driver for smartbond 2022-08-31 20:32:03 +02:00
Kconfig.sn74hc595 drivers: gpio: Update drivers to use devicetree Kconfig symbol 2022-07-23 09:26:09 -05:00
Kconfig.stellaris drivers: gpio: Update drivers to use devicetree Kconfig symbol 2022-07-23 09:26:09 -05:00
Kconfig.stm32 drivers: gpio: Update drivers to use devicetree Kconfig symbol 2022-07-23 09:26:09 -05:00
Kconfig.stmpe1600 drivers: gpio: Update drivers to use devicetree Kconfig symbol 2022-07-23 09:26:09 -05:00
Kconfig.sx1509b drivers: gpio: sx1509b: select I2C 2022-08-26 10:06:43 -07:00
Kconfig.tca6424a drivers: gpio: Add TCA6424A driver 2022-11-18 10:10:11 +01:00
Kconfig.test drivers: gpio: Cleanup Kconfig.test 2022-09-01 10:25:57 +02:00
Kconfig.xec drivers: gpio: Update drivers to use devicetree Kconfig symbol 2022-07-23 09:26:09 -05:00
Kconfig.xlnx drivers: gpio: Update drivers to use devicetree Kconfig symbol 2022-07-23 09:26:09 -05:00
Kconfig.xlnx_ps drivers: gpio: Update drivers to use devicetree Kconfig symbol 2022-07-23 09:26:09 -05:00
Kconfig.xmc4xxx drivers: gpio: Add xmc4xxx drivers 2022-08-05 13:00:21 +02:00