1 /* SPDX-License-Identifier: GPL-2.0+ */
4 * Vikas Manocha, <vikas.manocha@st.com>
11 #define STM32_GPIOS_PER_BANK 16
13 enum stm32_gpio_port {
14 STM32_GPIO_PORT_A = 0,
44 enum stm32_gpio_mode {
45 STM32_GPIO_MODE_IN = 0,
51 enum stm32_gpio_otype {
52 STM32_GPIO_OTYPE_PP = 0,
56 enum stm32_gpio_speed {
57 STM32_GPIO_SPEED_2M = 0,
63 enum stm32_gpio_pupd {
64 STM32_GPIO_PUPD_NO = 0,
88 struct stm32_gpio_dsc {
89 enum stm32_gpio_port port;
90 enum stm32_gpio_pin pin;
93 struct stm32_gpio_ctl {
94 enum stm32_gpio_mode mode;
95 enum stm32_gpio_otype otype;
96 enum stm32_gpio_speed speed;
97 enum stm32_gpio_pupd pupd;
98 enum stm32_gpio_af af;
101 struct stm32_gpio_regs {
102 u32 moder; /* GPIO port mode */
103 u32 otyper; /* GPIO port output type */
104 u32 ospeedr; /* GPIO port output speed */
105 u32 pupdr; /* GPIO port pull-up/pull-down */
106 u32 idr; /* GPIO port input data */
107 u32 odr; /* GPIO port output data */
108 u32 bsrr; /* GPIO port bit set/reset */
109 u32 lckr; /* GPIO port configuration lock */
110 u32 afr[2]; /* GPIO alternate function */
113 struct stm32_gpio_priv {
114 struct stm32_gpio_regs *regs;
115 unsigned int gpio_range;
118 int stm32_offset_to_index(struct udevice *dev, unsigned int offset);
120 #endif /* _STM32_GPIO_H_ */