Skip to content

Commit 1001585

Browse files
etienne-lmsjforissier
authored andcommitted
drivers: stm32_gpio: remove GPIO access specific API functions
Removes stm32_gpio API functions to access GPIOs as the driver has moved to the generic GPIO framework and consumer driver should use the generic API to access GPIOs. The driver now expects CFG_DRIVERS_GPIO is enabled. Acked-by: Gatien Chevallier <gatien.chevallier@foss.st.com> Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.com>
1 parent ca1a94a commit 1001585

File tree

2 files changed

+4
-94
lines changed

2 files changed

+4
-94
lines changed

core/drivers/stm32_gpio.c

+4-53
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* Copyright (c) 2017-2023, STMicroelectronics
44
*
55
* STM32 GPIO driver is used as pin controller for stm32mp SoCs.
6-
* The driver API is defined in header file stm32_gpio.h.
76
*/
87

98
#include <assert.h>
@@ -24,6 +23,10 @@
2423
#include <trace.h>
2524
#include <util.h>
2625

26+
#ifndef CFG_DRIVERS_GPIO
27+
#error stm32_gpio driver expects CFG_DRIVERS_GPIO
28+
#endif
29+
2730
#define GPIO_PIN_MAX 15
2831

2932
#define GPIO_MODER_OFFSET 0x00
@@ -765,58 +768,6 @@ int stm32_get_gpio_count(void *fdt, int pinctrl_node, unsigned int bank)
765768
return -1;
766769
}
767770

768-
static __maybe_unused bool valid_gpio_config(unsigned int bank_id,
769-
unsigned int pin, bool input)
770-
{
771-
struct stm32_gpio_bank *bank = stm32_gpio_get_bank(bank_id);
772-
uint32_t mode = (io_read32(bank->base + GPIO_MODER_OFFSET) >>
773-
(pin << 1)) & GPIO_MODE_MASK;
774-
775-
if (pin > GPIO_PIN_MAX)
776-
return false;
777-
778-
if (input)
779-
return mode == GPIO_MODE_INPUT;
780-
else
781-
return mode == GPIO_MODE_OUTPUT;
782-
}
783-
784-
int stm32_gpio_get_input_level(unsigned int bank_id, unsigned int pin)
785-
{
786-
struct stm32_gpio_bank *bank = stm32_gpio_get_bank(bank_id);
787-
int rc = 0;
788-
789-
if (clk_enable(bank->clock))
790-
panic();
791-
792-
assert(valid_gpio_config(bank_id, pin, true));
793-
794-
if (io_read32(bank->base + GPIO_IDR_OFFSET) == BIT(pin))
795-
rc = 1;
796-
797-
clk_disable(bank->clock);
798-
799-
return rc;
800-
}
801-
802-
void stm32_gpio_set_output_level(unsigned int bank_id, unsigned int pin,
803-
int level)
804-
{
805-
struct stm32_gpio_bank *bank = stm32_gpio_get_bank(bank_id);
806-
807-
if (clk_enable(bank->clock))
808-
panic();
809-
810-
assert(valid_gpio_config(bank_id, pin, false));
811-
812-
if (level)
813-
io_write32(bank->base + GPIO_BSRR_OFFSET, BIT(pin));
814-
else
815-
io_write32(bank->base + GPIO_BSRR_OFFSET, BIT(pin + 16));
816-
817-
clk_disable(bank->clock);
818-
}
819-
820771
void stm32_gpio_set_secure_cfg(unsigned int bank_id, unsigned int pin,
821772
bool secure)
822773
{

core/include/drivers/stm32_gpio.h

-41
Original file line numberDiff line numberDiff line change
@@ -111,47 +111,6 @@ void stm32_pinctrl_store_standby_cfg(struct stm32_pinctrl *pinctrl, size_t cnt);
111111
int stm32_pinctrl_fdt_get_pinctrl(void *fdt, int node,
112112
struct stm32_pinctrl *pinctrl, size_t count);
113113

114-
/*
115-
* Set target output GPIO pin to high or low level
116-
*
117-
* @bank: GPIO bank identifier as assigned by the platform
118-
* @pin: GPIO pin position in the GPIO bank
119-
* @high: 1 to set GPIO to high level, 0 to set to GPIO low level
120-
*/
121-
void stm32_gpio_set_output_level(unsigned int bank, unsigned int pin, int high);
122-
123-
/*
124-
* Set output GPIO pin referenced by @pinctrl to high or low level
125-
*
126-
* @pinctrl: Reference to pinctrl
127-
* @high: 1 to set GPIO to high level, 0 to set to GPIO low level
128-
*/
129-
static inline void stm32_pinctrl_set_gpio_level(struct stm32_pinctrl *pinctrl,
130-
int high)
131-
{
132-
stm32_gpio_set_output_level(pinctrl->bank, pinctrl->pin, high);
133-
}
134-
135-
/*
136-
* Get input GPIO pin current level, high or low
137-
*
138-
* @bank: GPIO bank identifier as assigned by the platform
139-
* @pin: GPIO pin position in the GPIO bank
140-
* Return 1 if GPIO level is high, 0 if it is low
141-
*/
142-
int stm32_gpio_get_input_level(unsigned int bank, unsigned int pin);
143-
144-
/*
145-
* Set target output GPIO pin to high or low level
146-
*
147-
* @pinctrl: Reference to pinctrl
148-
* Return 1 if GPIO level is high, 0 if it is low
149-
*/
150-
static inline int stm32_pinctrl_get_gpio_level(struct stm32_pinctrl *pinctrl)
151-
{
152-
return stm32_gpio_get_input_level(pinctrl->bank, pinctrl->pin);
153-
}
154-
155114
#ifdef CFG_STM32_GPIO
156115
/*
157116
* Configure pin muxing access permission: can be secure or not

0 commit comments

Comments
 (0)