[PATCH v1 2/8] ARM: at91: Provide at91_mux_pio_pin for use in lowlevel
Sam Ravnborg
sam at ravnborg.org
Sun May 15 12:38:01 PDT 2022
Lowlevel init code may wish the ability to configure pins, e.g. for low
level debug UART. The pinctrl-at91 driver already exports an
at91_mux_pin function, but that one is only usable after driver
probe. Instead, provide an at91_mux_pio_pin function, which can be used
at all times.
This is similar to the already existing at91_mux_pio3_pin function
Signed-off-by: Sam Ravnborg <sam at ravnborg.org>
---
arch/arm/mach-at91/include/mach/gpio.h | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/arch/arm/mach-at91/include/mach/gpio.h b/arch/arm/mach-at91/include/mach/gpio.h
index ddd6971e3..7f84f41e5 100644
--- a/arch/arm/mach-at91/include/mach/gpio.h
+++ b/arch/arm/mach-at91/include/mach/gpio.h
@@ -151,6 +151,31 @@ static inline int at91_mux_gpio_get(void __iomem *pio, unsigned mask)
return (pdsr & mask) != 0;
}
+static inline void at91_mux_pio_pin(void __iomem *pio, unsigned mask,
+ enum at91_mux mux, int gpio_state)
+{
+ at91_mux_disable_interrupt(pio, mask);
+
+ switch(mux) {
+ case AT91_MUX_GPIO:
+ at91_mux_gpio_enable(pio, mask);
+ break;
+ case AT91_MUX_PERIPH_A:
+ at91_mux_set_A_periph(pio, mask);
+ break;
+ case AT91_MUX_PERIPH_B:
+ at91_mux_set_B_periph(pio, mask);
+ break;
+ default:
+ /* ignore everything else */
+ break;
+ }
+ if (mux != AT91_MUX_GPIO)
+ at91_mux_gpio_disable(pio, mask);
+
+ at91_mux_set_pullup(pio, mask, gpio_state & GPIO_PULL_UP);
+}
+
static inline void at91_mux_pio3_pin(void __iomem *pio, unsigned mask,
enum at91_mux mux, int gpio_state)
{
--
2.34.1
More information about the barebox
mailing list