mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <ahmad@a3f.at>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <ahmad@a3f.at>
Subject: [PATCH] pinctrl: stm32: replace magic values with defines for STM32_PINMODE
Date: Fri, 14 Jan 2022 07:59:43 +0100	[thread overview]
Message-ID: <20220114065943.698337-1-ahmad@a3f.at> (raw)

Makes the code easier to follow and allows using the new macros in PBL
code for early pinmuxing of e.g. the debug UART.

Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
---
 drivers/pinctrl/pinctrl-stm32.c | 6 +++---
 include/soc/stm32/gpio.h        | 4 ++++
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-stm32.c b/drivers/pinctrl/pinctrl-stm32.c
index 9b5b04b6d6a8..ceaa4254c4d0 100644
--- a/drivers/pinctrl/pinctrl-stm32.c
+++ b/drivers/pinctrl/pinctrl-stm32.c
@@ -63,11 +63,11 @@ static inline u32 stm32_gpio_get_mode(u32 function)
 {
 	switch (function) {
 	case STM32_PIN_GPIO:
-		return 0;
+		return STM32_PINMODE_GPIO;
 	case STM32_PIN_AF(0) ... STM32_PIN_AF(15):
-		return 2;
+		return STM32_PINMODE_AF;
 	case STM32_PIN_ANALOG:
-		return 3;
+		return STM32_PINMODE_ANALOG;
 	}
 
 	return 0;
diff --git a/include/soc/stm32/gpio.h b/include/soc/stm32/gpio.h
index 13b492a6937c..448fb19e2ef8 100644
--- a/include/soc/stm32/gpio.h
+++ b/include/soc/stm32/gpio.h
@@ -25,6 +25,10 @@
 #define STM32_PIN_AF(x)		((x) + 1)
 #define STM32_PIN_ANALOG	(STM32_PIN_AF(15) + 1)
 
+#define STM32_PINMODE_GPIO	0
+#define STM32_PINMODE_AF	2
+#define STM32_PINMODE_ANALOG	3
+
 #define STM32_GPIO_PINS_PER_BANK	16
 
 enum stm32_pin_bias { STM32_PIN_NO_BIAS, STM32_PIN_PULL_UP, STM32_PIN_PULL_DOWN };
-- 
2.33.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


             reply	other threads:[~2022-01-14  7:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-14  6:59 Ahmad Fatoum [this message]
2022-01-14  8:24 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220114065943.698337-1-ahmad@a3f.at \
    --to=ahmad@a3f.at \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox