xref: /optee_os/core/include/drivers/stm32_gpio.h (revision 82a84a88ae5cc840ad50ef088beaa416b1e86a2c)
1 /* SPDX-License-Identifier: BSD-3-Clause */
2 /*
3  * Copyright (c) 2017-2023, STMicroelectronics
4  */
5 
6 #ifndef __DRIVERS_STM32_GPIO_H
7 #define __DRIVERS_STM32_GPIO_H
8 
9 #include <assert.h>
10 #include <drivers/gpio.h>
11 #include <drivers/pinctrl.h>
12 #include <stdbool.h>
13 #include <stdint.h>
14 #include <stddef.h>
15 
16 struct pinctrl_state;
17 struct stm32_pinctrl;
18 
19 #ifdef CFG_STM32_GPIO
20 /*
21  * Get the bank and pin indices related to a pin control state
22  * @pinctrl: Pinctrl state
23  * @bank: Output bank indices array or NULL
24  * @pin: Output pin indices array or NULL
25  * @count: [in] Number of cells of @bank and @pin, [out] pin count in @pinctrl
26  */
27 void stm32_gpio_pinctrl_bank_pin(struct pinctrl_state *pinctrl,
28 				 unsigned int *bank, unsigned int *pin,
29 				 unsigned int *count);
30 
31 /*
32  * stm32_gpio_chip_bank_id() - Get the GPIO bank ID associated to a chip
33  * @chip: GPIO chip associated to the bank
34  */
35 unsigned int stm32_gpio_chip_bank_id(struct gpio_chip *chip);
36 #else
37 static inline void stm32_gpio_pinctrl_bank_pin(struct pinctrl_state *p __unused,
38 					       unsigned int *bank __unused,
39 					       unsigned int *pin __unused,
40 					       unsigned int *count __unused)
41 {
42 }
43 
44 static inline unsigned int __noreturn
45 stm32_gpio_chip_bank_id(struct gpio_chip *chip __unused)
46 {
47 	panic();
48 }
49 #endif /*CFG_STM32_GPIO*/
50 #endif /*__DRIVERS_STM32_GPIO_H*/
51