Skip to content

Commit

Permalink
drivers: stm32_gpio: move definitions to source file
Browse files Browse the repository at this point in the history
Moves macros and structures definitions from stm32_gpio.h header file
to the driver source file as these definition do not need to be
visible from other drivers thank to pin control abstraction.

Acked-by: Gatien Chevallier <[email protected]>
Signed-off-by: Etienne Carriere <[email protected]>
  • Loading branch information
etienne-lms authored and jforissier committed Jul 31, 2023
1 parent 9ef7a09 commit 69715ce
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 54 deletions.
55 changes: 55 additions & 0 deletions core/drivers/stm32_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

#include <assert.h>
#include <compiler.h>
#include <drivers/clk.h>
#include <drivers/clk_dt.h>
#include <drivers/gpio.h>
Expand All @@ -19,6 +20,7 @@
#include <libfdt.h>
#include <mm/core_memprot.h>
#include <stdbool.h>
#include <stdint.h>
#include <stm32_util.h>
#include <sys/queue.h>
#include <trace.h>
Expand Down Expand Up @@ -56,6 +58,59 @@

#define DT_GPIO_BANK_NAME0 "GPIOA"

#define GPIO_MODE_INPUT U(0x0)
#define GPIO_MODE_OUTPUT U(0x1)
#define GPIO_MODE_ALTERNATE U(0x2)
#define GPIO_MODE_ANALOG U(0x3)

#define GPIO_OTYPE_PUSH_PULL U(0x0)
#define GPIO_OTYPE_OPEN_DRAIN U(0x1)

#define GPIO_OSPEED_LOW U(0x0)
#define GPIO_OSPEED_MEDIUM U(0x1)
#define GPIO_OSPEED_HIGH U(0x2)
#define GPIO_OSPEED_VERY_HIGH U(0x3)

#define GPIO_PUPD_NO_PULL U(0x0)
#define GPIO_PUPD_PULL_UP U(0x1)
#define GPIO_PUPD_PULL_DOWN U(0x2)

#define GPIO_OD_LEVEL_LOW U(0x0)
#define GPIO_OD_LEVEL_HIGH U(0x1)

/*
* GPIO configuration description structured as single 16bit word
* for efficient save/restore when GPIO pin suspends or resumes.
*
* @mode: One of GPIO_MODE_*
* @otype: One of GPIO_OTYPE_*
* @ospeed: One of GPIO_OSPEED_*
* @pupd: One of GPIO_PUPD_*
* @od: One of GPIO_OD_*
* @af: Alternate function numerical ID between 0 and 15
*/
struct gpio_cfg {
uint16_t mode: 2;
uint16_t otype: 1;
uint16_t ospeed: 2;
uint16_t pupd: 2;
uint16_t od: 1;
uint16_t af: 4;
};

/*
* Description of a pin and its muxing
*
* @bank: GPIO bank identifier as assigned by the platform
* @pin: Pin number in the GPIO bank
* @cfg: Pin configuration
*/
struct stm32_pinctrl {
uint8_t bank;
uint8_t pin;
struct gpio_cfg cfg;
};

/*
* struct stm32_pinctrl_array - Array of pins in a pin control state
* @count: Number of cells in @pinctrl
Expand Down
55 changes: 1 addition & 54 deletions core/include/drivers/stm32_gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,66 +7,13 @@
#define DRIVERS_STM32_GPIO_H

#include <assert.h>
#include <compiler.h>
#include <drivers/pinctrl.h>
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>

#define GPIO_MODE_INPUT 0x0
#define GPIO_MODE_OUTPUT 0x1
#define GPIO_MODE_ALTERNATE 0x2
#define GPIO_MODE_ANALOG 0x3

#define GPIO_OTYPE_PUSH_PULL 0x0
#define GPIO_OTYPE_OPEN_DRAIN 0x1

#define GPIO_OSPEED_LOW 0x0
#define GPIO_OSPEED_MEDIUM 0x1
#define GPIO_OSPEED_HIGH 0x2
#define GPIO_OSPEED_VERY_HIGH 0x3

#define GPIO_PUPD_NO_PULL 0x0
#define GPIO_PUPD_PULL_UP 0x1
#define GPIO_PUPD_PULL_DOWN 0x2

#define GPIO_OD_LEVEL_LOW 0x0
#define GPIO_OD_LEVEL_HIGH 0x1

struct pinctrl_state;

/*
* GPIO configuration description structured as single 16bit word
* for efficient save/restore when GPIO pin suspends or resumes.
*
* @mode: One of GPIO_MODE_*
* @otype: One of GPIO_OTYPE_*
* @ospeed: One of GPIO_OSPEED_*
* @pupd: One of GPIO_PUPD_*
* @od: One of GPIO_OD_*
* @af: Alternate function numerical ID between 0 and 15
*/
struct gpio_cfg {
uint16_t mode: 2;
uint16_t otype: 1;
uint16_t ospeed: 2;
uint16_t pupd: 2;
uint16_t od: 1;
uint16_t af: 4;
};

/*
* Description of a pin and its muxing
*
* @bank: GPIO bank identifier as assigned by the platform
* @pin: Pin number in the GPIO bank
* @cfg: Pin configuration
*/
struct stm32_pinctrl {
uint8_t bank;
uint8_t pin;
struct gpio_cfg cfg;
};
struct stm32_pinctrl;

#ifdef CFG_STM32_GPIO
/*
Expand Down

0 comments on commit 69715ce

Please sign in to comment.