1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright (C) 2016, STMicroelectronics - All Rights Reserved
4 * Author(s): Vikas Manocha, <vikas.manocha@st.com> for STMicroelectronics.
7 #ifndef _STM32_GPIO_PRIV_H_
8 #define _STM32_GPIO_PRIV_H_
10 enum stm32_gpio_mode {
11 STM32_GPIO_MODE_IN = 0,
17 enum stm32_gpio_otype {
18 STM32_GPIO_OTYPE_PP = 0,
22 enum stm32_gpio_speed {
23 STM32_GPIO_SPEED_2M = 0,
29 enum stm32_gpio_pupd {
30 STM32_GPIO_PUPD_NO = 0,
54 struct stm32_gpio_dsc {
59 struct stm32_gpio_ctl {
60 enum stm32_gpio_mode mode;
61 enum stm32_gpio_otype otype;
62 enum stm32_gpio_speed speed;
63 enum stm32_gpio_pupd pupd;
64 enum stm32_gpio_af af;
67 struct stm32_gpio_regs {
68 u32 moder; /* GPIO port mode */
69 u32 otyper; /* GPIO port output type */
70 u32 ospeedr; /* GPIO port output speed */
71 u32 pupdr; /* GPIO port pull-up/pull-down */
72 u32 idr; /* GPIO port input data */
73 u32 odr; /* GPIO port output data */
74 u32 bsrr; /* GPIO port bit set/reset */
75 u32 lckr; /* GPIO port configuration lock */
76 u32 afr[2]; /* GPIO alternate function */
79 struct stm32_gpio_priv {
80 struct stm32_gpio_regs *regs;
81 unsigned int gpio_range;
84 int stm32_offset_to_index(struct udevice *dev, unsigned int offset);
86 #endif /* _STM32_GPIO_PRIV_H_ */