Skip to contentSkip to conversation

arm: stm32: cleanup arch gpio.h

PATCH New Patrick Delaunay 2 participants 3 messages Oct 2, 2020 – Oct 21, 2020

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm: stm32: cleanup arch gpio.h

Cosmetic update of gpio.h:
- remove enumerate: stm32_gpio_port, stm32_gpio_pin because STM32_GPIO_XXX values are unused
- move STM32_GPIOS_PER_BANK in stm32_gpio.c as its value is IP dependent and not arch dependent

No functional change as number of banks and number of gpio by banks is managed by device tree since since DM migration and commit 8f651ca60ba1 ("pinctrl: stm32: Add get_pins_count() ops").

---

 arch/arm/include/asm/arch-stm32/gpio.h    | 37 ++---------------------
 arch/arm/mach-stm32mp/include/mach/gpio.h | 37 ++---------------------
 drivers/gpio/stm32_gpio.c                 |  2 ++
 3 files changed, 6 insertions(+), 70 deletions(-)
arch/arm/include/asm/arch-stm32/gpio.h +2 -35
index 570e80a6ba..233ce278a7 100644
@@ -7,39 +7,6 @@
 #ifndef _GPIO_H_
 #define _GPIO_H_
 
-#define STM32_GPIOS_PER_BANK		16
-
-enum stm32_gpio_port {
-	STM32_GPIO_PORT_A = 0,
-	STM32_GPIO_PORT_B,
-	STM32_GPIO_PORT_C,
-	STM32_GPIO_PORT_D,
-	STM32_GPIO_PORT_E,
-	STM32_GPIO_PORT_F,
-	STM32_GPIO_PORT_G,
-	STM32_GPIO_PORT_H,
-	STM32_GPIO_PORT_I
-};
-
-enum stm32_gpio_pin {
-	STM32_GPIO_PIN_0 = 0,
-	STM32_GPIO_PIN_1,
-	STM32_GPIO_PIN_2,
-	STM32_GPIO_PIN_3,
-	STM32_GPIO_PIN_4,
-	STM32_GPIO_PIN_5,
-	STM32_GPIO_PIN_6,
-	STM32_GPIO_PIN_7,
-	STM32_GPIO_PIN_8,
-	STM32_GPIO_PIN_9,
-	STM32_GPIO_PIN_10,
-	STM32_GPIO_PIN_11,
-	STM32_GPIO_PIN_12,
-	STM32_GPIO_PIN_13,
-	STM32_GPIO_PIN_14,
-	STM32_GPIO_PIN_15
-};
-
 enum stm32_gpio_mode {
 	STM32_GPIO_MODE_IN = 0,
 	STM32_GPIO_MODE_OUT,
@@ -85,8 +52,8 @@ enum stm32_gpio_af {
 };
 
 struct stm32_gpio_dsc {
-	enum stm32_gpio_port	port;
-	enum stm32_gpio_pin	pin;
+	u8	port;
+	u8	pin;
 };
 
 struct stm32_gpio_ctl {
arch/arm/mach-stm32mp/include/mach/gpio.h +2 -35
index 5ca76d21ff..7a0f293519 100644
@@ -8,39 +8,6 @@
 #define _STM32_GPIO_H_
 #include <asm/gpio.h>
 
-#define STM32_GPIOS_PER_BANK		16
-
-enum stm32_gpio_port {
-	STM32_GPIO_PORT_A = 0,
-	STM32_GPIO_PORT_B,
-	STM32_GPIO_PORT_C,
-	STM32_GPIO_PORT_D,
-	STM32_GPIO_PORT_E,
-	STM32_GPIO_PORT_F,
-	STM32_GPIO_PORT_G,
-	STM32_GPIO_PORT_H,
-	STM32_GPIO_PORT_I
-};
-
-enum stm32_gpio_pin {
-	STM32_GPIO_PIN_0 = 0,
-	STM32_GPIO_PIN_1,
-	STM32_GPIO_PIN_2,
-	STM32_GPIO_PIN_3,
-	STM32_GPIO_PIN_4,
-	STM32_GPIO_PIN_5,
-	STM32_GPIO_PIN_6,
-	STM32_GPIO_PIN_7,
-	STM32_GPIO_PIN_8,
-	STM32_GPIO_PIN_9,
-	STM32_GPIO_PIN_10,
-	STM32_GPIO_PIN_11,
-	STM32_GPIO_PIN_12,
-	STM32_GPIO_PIN_13,
-	STM32_GPIO_PIN_14,
-	STM32_GPIO_PIN_15
-};
-
 enum stm32_gpio_mode {
 	STM32_GPIO_MODE_IN = 0,
 	STM32_GPIO_MODE_OUT,
@@ -86,8 +53,8 @@ enum stm32_gpio_af {
 };
 
 struct stm32_gpio_dsc {
-	enum stm32_gpio_port	port;
-	enum stm32_gpio_pin	pin;
+	u8	port;
+	u8	pin;
 };
 
 struct stm32_gpio_ctl {
drivers/gpio/stm32_gpio.c +2 -0
index 5bff27f75b..9ea2a03f15 100644
@@ -18,6 +18,8 @@
 #include <linux/errno.h>
 #include <linux/io.h>
 
+#define STM32_GPIOS_PER_BANK		16
+
 #define MODE_BITS(gpio_pin)		((gpio_pin) * 2)
 #define MODE_BITS_MASK			3
 #define BSRR_BIT(gpio_pin, value)	BIT((gpio_pin) + (value ? 0 : 16))
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 arm: stm32: cleanup arch gpio.h

Hi Patrick

Quoted 133 lines · Patrick Delaunay

Cosmetic update of gpio.h:
- remove enumerate: stm32_gpio_port, stm32_gpio_pin because STM32_GPIO_XXX values are unused
- move STM32_GPIOS_PER_BANK in stm32_gpio.c as its value is IP dependent and not arch dependent

No functional change as number of banks and number of gpio by banks is managed by device tree since since DM migration and commit 8f651ca60ba1 ("pinctrl: stm32: Add get_pins_count() ops").

---

 arch/arm/include/asm/arch-stm32/gpio.h    | 37 ++---------------------
 arch/arm/mach-stm32mp/include/mach/gpio.h | 37 ++---------------------
 drivers/gpio/stm32_gpio.c                 |  2 ++
 3 files changed, 6 insertions(+), 70 deletions(-)
arch/arm/include/asm/arch-stm32/gpio.h +2 -35
index 570e80a6ba..233ce278a7 100644
@@ -7,39 +7,6 @@
 #ifndef _GPIO_H_
 #define _GPIO_H_
 
-#define STM32_GPIOS_PER_BANK		16
-
-enum stm32_gpio_port {
-	STM32_GPIO_PORT_A = 0,
-	STM32_GPIO_PORT_B,
-	STM32_GPIO_PORT_C,
-	STM32_GPIO_PORT_D,
-	STM32_GPIO_PORT_E,
-	STM32_GPIO_PORT_F,
-	STM32_GPIO_PORT_G,
-	STM32_GPIO_PORT_H,
-	STM32_GPIO_PORT_I
-};
-
-enum stm32_gpio_pin {
-	STM32_GPIO_PIN_0 = 0,
-	STM32_GPIO_PIN_1,
-	STM32_GPIO_PIN_2,
-	STM32_GPIO_PIN_3,
-	STM32_GPIO_PIN_4,
-	STM32_GPIO_PIN_5,
-	STM32_GPIO_PIN_6,
-	STM32_GPIO_PIN_7,
-	STM32_GPIO_PIN_8,
-	STM32_GPIO_PIN_9,
-	STM32_GPIO_PIN_10,
-	STM32_GPIO_PIN_11,
-	STM32_GPIO_PIN_12,
-	STM32_GPIO_PIN_13,
-	STM32_GPIO_PIN_14,
-	STM32_GPIO_PIN_15
-};
-
 enum stm32_gpio_mode {
 	STM32_GPIO_MODE_IN = 0,
 	STM32_GPIO_MODE_OUT,
@@ -85,8 +52,8 @@ enum stm32_gpio_af {
 };
 
 struct stm32_gpio_dsc {
-	enum stm32_gpio_port	port;
-	enum stm32_gpio_pin	pin;
+	u8	port;
+	u8	pin;
 };
 
 struct stm32_gpio_ctl {
arch/arm/mach-stm32mp/include/mach/gpio.h +2 -35
index 5ca76d21ff..7a0f293519 100644
@@ -8,39 +8,6 @@
 #define _STM32_GPIO_H_
 #include <asm/gpio.h>
 
-#define STM32_GPIOS_PER_BANK		16
-
-enum stm32_gpio_port {
-	STM32_GPIO_PORT_A = 0,
-	STM32_GPIO_PORT_B,
-	STM32_GPIO_PORT_C,
-	STM32_GPIO_PORT_D,
-	STM32_GPIO_PORT_E,
-	STM32_GPIO_PORT_F,
-	STM32_GPIO_PORT_G,
-	STM32_GPIO_PORT_H,
-	STM32_GPIO_PORT_I
-};
-
-enum stm32_gpio_pin {
-	STM32_GPIO_PIN_0 = 0,
-	STM32_GPIO_PIN_1,
-	STM32_GPIO_PIN_2,
-	STM32_GPIO_PIN_3,
-	STM32_GPIO_PIN_4,
-	STM32_GPIO_PIN_5,
-	STM32_GPIO_PIN_6,
-	STM32_GPIO_PIN_7,
-	STM32_GPIO_PIN_8,
-	STM32_GPIO_PIN_9,
-	STM32_GPIO_PIN_10,
-	STM32_GPIO_PIN_11,
-	STM32_GPIO_PIN_12,
-	STM32_GPIO_PIN_13,
-	STM32_GPIO_PIN_14,
-	STM32_GPIO_PIN_15
-};
-
 enum stm32_gpio_mode {
 	STM32_GPIO_MODE_IN = 0,
 	STM32_GPIO_MODE_OUT,
@@ -86,8 +53,8 @@ enum stm32_gpio_af {
 };
 
 struct stm32_gpio_dsc {
-	enum stm32_gpio_port	port;
-	enum stm32_gpio_pin	pin;
+	u8	port;
+	u8	pin;
 };
 
 struct stm32_gpio_ctl {
drivers/gpio/stm32_gpio.c +0 -0
index 5bff27f75b..9ea2a03f15 100644

drivers/gpio/stm32_gpio.c line 25

Quoted 8 lines
drivers/gpio/stm32_gpio.c +2 -0
@@ -18,6 +18,8 @@
 #include <linux/errno.h>
 #include <linux/io.h>
 
+#define STM32_GPIOS_PER_BANK		16
+
 #define MODE_BITS(gpio_pin)		((gpio_pin) * 2)
 #define MODE_BITS_MASK			3
 #define BSRR_BIT(gpio_pin, value)	BIT((gpio_pin) + (value ? 0 : 16))

Thanks

#2 lore raw

PATCH 1/1 arm: stm32: cleanup arch gpio.h

In reply to Patrick Delaunay

Hi,

Quoted 13 lines

From: Patrick DELAUNAY <[email protected]>
Sent: vendredi 2 octobre 2020 14:09

Cosmetic update of gpio.h:
- remove enumerate: stm32_gpio_port, stm32_gpio_pin because STM32_GPIO_XXX values are unused
- move STM32_GPIOS_PER_BANK in stm32_gpio.c as its value is IP dependent and not arch dependent

No functional change as number of banks and number of gpio by banks is managed by device tree since since DM migration and commit 8f651ca60ba1 ("pinctrl: stm32: Add get_pins_count() ops").

Quoted 8 lines

---

 arch/arm/include/asm/arch-stm32/gpio.h    | 37 ++---------------------
 arch/arm/mach-stm32mp/include/mach/gpio.h | 37 ++---------------------
 drivers/gpio/stm32_gpio.c                 |  2 ++
 3 files changed, 6 insertions(+), 70 deletions(-)

Applied to u-boot-stm/master, thanks!

Regards

Patrick