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/pinctrl.h> 11 #include <stdbool.h> 12 #include <stdint.h> 13 #include <stddef.h> 14 15 struct pinctrl_state; 16 struct stm32_pinctrl; 17 18 #ifdef CFG_STM32_GPIO 19 /* 20 * Configure pin muxing access permission: can be secure or not 21 * 22 * @bank: GPIO bank identifier as assigned by the platform 23 * @pin: Pin number in the GPIO bank 24 * @secure: True if pin is secure, false otherwise 25 */ 26 void stm32_gpio_set_secure_cfg(unsigned int bank, unsigned int pin, 27 bool secure); 28 29 /* 30 * Configure pin muxing access permission: can be secure or not 31 * 32 * @pinctrl: Pin control state where STM32_GPIO pin are to configure 33 * @secure: True if pin is secure, false otherwise 34 */ 35 void stm32_pinctrl_set_secure_cfg(struct pinctrl_state *pinctrl, bool secure); 36 37 /* 38 * Get the bank and pin indices related to a pin control state 39 * @pinctrl: Pinctrl state 40 * @bank: Output bank indices array or NULL 41 * @pin: Output pin indices array or NULL 42 * @count: [in] Number of cells of @bank and @pin, [out] pin count in @pinctrl 43 */ 44 void stm32_gpio_pinctrl_bank_pin(struct pinctrl_state *pinctrl, 45 unsigned int *bank, unsigned int *pin, 46 unsigned int *count); 47 #else 48 static inline void 49 stm32_pinctrl_set_secure_cfg(struct pinctrl_state *pinctrl __unused, 50 bool secure __unused) 51 { 52 } 53 54 static inline void stm32_gpio_pinctrl_bank_pin(struct pinctrl_state *p __unused, 55 unsigned int *bank __unused, 56 unsigned int *pin __unused, 57 unsigned int *count __unused) 58 { 59 } 60 #endif /*CFG_STM32_GPIO*/ 61 #endif /*__DRIVERS_STM32_GPIO_H*/ 62