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 * Get the number of GPIO pins supported by a target GPIO bank 31 * 32 * @fdt: device tree reference 33 * @pinctrl_node: pinctrl node which GPIO bank node belongs to 34 * @bank: target GPIO bank ID 35 * Return number of GPIO pins (>= 0) or a negative value on error 36 */ 37 int stm32_get_gpio_count(void *fdt, int pinctrl_node, unsigned int bank); 38 39 /* 40 * Configure pin muxing access permission: can be secure or not 41 * 42 * @pinctrl: Pin control state where STM32_GPIO pin are to configure 43 * @secure: True if pin is secure, false otherwise 44 */ 45 void stm32_pinctrl_set_secure_cfg(struct pinctrl_state *pinctrl, bool secure); 46 47 /* 48 * Get the bank and pin indices related to a pin control state 49 * @pinctrl: Pinctrl state 50 * @bank: Output bank indices array or NULL 51 * @pin: Output pin indices array or NULL 52 * @count: [in] Number of cells of @bank and @pin, [out] pin count in @pinctrl 53 */ 54 void stm32_gpio_pinctrl_bank_pin(struct pinctrl_state *pinctrl, 55 unsigned int *bank, unsigned int *pin, 56 unsigned int *count); 57 #else 58 static inline void 59 stm32_pinctrl_set_secure_cfg(struct pinctrl_state *pinctrl __unused, 60 bool secure __unused) 61 { 62 } 63 64 static inline void stm32_gpio_pinctrl_bank_pin(struct pinctrl_state *p __unused, 65 unsigned int *bank __unused, 66 unsigned int *pin __unused, 67 unsigned int *count __unused) 68 { 69 } 70 #endif /*CFG_STM32_GPIO*/ 71 #endif /*__DRIVERS_STM32_GPIO_H*/ 72