Yann Gautier | d0ca7f4 | 2018-07-13 21:33:09 +0200 | [diff] [blame] | 1 | /* |
Yann Gautier | 1a3fc9f | 2019-01-17 14:35:22 +0100 | [diff] [blame] | 2 | * Copyright (c) 2015-2019, STMicroelectronics - All Rights Reserved |
Yann Gautier | d0ca7f4 | 2018-07-13 21:33:09 +0200 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 7 | #ifndef STM32_GPIO_H |
| 8 | #define STM32_GPIO_H |
Yann Gautier | d0ca7f4 | 2018-07-13 21:33:09 +0200 | [diff] [blame] | 9 | |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 10 | #include <lib/utils_def.h> |
Yann Gautier | d0ca7f4 | 2018-07-13 21:33:09 +0200 | [diff] [blame] | 11 | |
Yann Gautier | d0ca7f4 | 2018-07-13 21:33:09 +0200 | [diff] [blame] | 12 | #define GPIO_MODE_OFFSET U(0x00) |
| 13 | #define GPIO_TYPE_OFFSET U(0x04) |
| 14 | #define GPIO_SPEED_OFFSET U(0x08) |
| 15 | #define GPIO_PUPD_OFFSET U(0x0C) |
| 16 | #define GPIO_BSRR_OFFSET U(0x18) |
| 17 | #define GPIO_AFRL_OFFSET U(0x20) |
| 18 | #define GPIO_AFRH_OFFSET U(0x24) |
Yann Gautier | 038bff2 | 2019-01-17 19:17:47 +0100 | [diff] [blame] | 19 | #define GPIO_SECR_OFFSET U(0x30) |
Yann Gautier | d0ca7f4 | 2018-07-13 21:33:09 +0200 | [diff] [blame] | 20 | |
| 21 | #define GPIO_ALT_LOWER_LIMIT U(0x08) |
| 22 | |
Yann Gautier | 038bff2 | 2019-01-17 19:17:47 +0100 | [diff] [blame] | 23 | #define GPIO_PIN_(_x) U(_x) |
| 24 | #define GPIO_PIN_MAX GPIO_PIN_(15) |
Yann Gautier | d0ca7f4 | 2018-07-13 21:33:09 +0200 | [diff] [blame] | 25 | |
Yann Gautier | 038bff2 | 2019-01-17 19:17:47 +0100 | [diff] [blame] | 26 | #define GPIO_ALTERNATE_(_x) U(_x) |
Yann Gautier | d0ca7f4 | 2018-07-13 21:33:09 +0200 | [diff] [blame] | 27 | #define GPIO_ALTERNATE_MASK U(0x0F) |
| 28 | |
| 29 | #define GPIO_MODE_INPUT 0x00 |
| 30 | #define GPIO_MODE_OUTPUT 0x01 |
| 31 | #define GPIO_MODE_ALTERNATE 0x02 |
| 32 | #define GPIO_MODE_ANALOG 0x03 |
| 33 | #define GPIO_MODE_MASK U(0x03) |
| 34 | |
| 35 | #define GPIO_OPEN_DRAIN U(0x10) |
| 36 | |
| 37 | #define GPIO_SPEED_LOW 0x00 |
| 38 | #define GPIO_SPEED_MEDIUM 0x01 |
Yann Gautier | 1a3fc9f | 2019-01-17 14:35:22 +0100 | [diff] [blame] | 39 | #define GPIO_SPEED_HIGH 0x02 |
| 40 | #define GPIO_SPEED_VERY_HIGH 0x03 |
Yann Gautier | d0ca7f4 | 2018-07-13 21:33:09 +0200 | [diff] [blame] | 41 | #define GPIO_SPEED_MASK U(0x03) |
| 42 | |
| 43 | #define GPIO_NO_PULL 0x00 |
| 44 | #define GPIO_PULL_UP 0x01 |
| 45 | #define GPIO_PULL_DOWN 0x02 |
| 46 | #define GPIO_PULL_MASK U(0x03) |
| 47 | |
Julius Werner | 53456fc | 2019-07-09 13:49:11 -0700 | [diff] [blame] | 48 | #ifndef __ASSEMBLER__ |
Yann Gautier | d0ca7f4 | 2018-07-13 21:33:09 +0200 | [diff] [blame] | 49 | #include <stdint.h> |
| 50 | |
Yann Gautier | 038bff2 | 2019-01-17 19:17:47 +0100 | [diff] [blame] | 51 | int dt_set_pinctrl_config(int node); |
Yann Gautier | d0ca7f4 | 2018-07-13 21:33:09 +0200 | [diff] [blame] | 52 | void set_gpio(uint32_t bank, uint32_t pin, uint32_t mode, uint32_t speed, |
Yann Gautier | 038bff2 | 2019-01-17 19:17:47 +0100 | [diff] [blame] | 53 | uint32_t pull, uint32_t alternate, uint8_t status); |
| 54 | void set_gpio_secure_cfg(uint32_t bank, uint32_t pin, bool secure); |
Julius Werner | 53456fc | 2019-07-09 13:49:11 -0700 | [diff] [blame] | 55 | #endif /*__ASSEMBLER__*/ |
Yann Gautier | d0ca7f4 | 2018-07-13 21:33:09 +0200 | [diff] [blame] | 56 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 57 | #endif /* STM32_GPIO_H */ |