From: Ludovic Desroches <[email protected]>

When a pin is muxed to a peripheral or as a GPIO, the only
configuration that can be set is the pullup. It is too restrictive
so this patch allows to give a full configuration.

Signed-off-by: Ludovic Desroches <[email protected]>
---
 arch/arm/mach-at91/include/mach/atmel_pio4.h    | 16 +++++------
 board/atmel/sama5d27_som1_ek/sama5d27_som1_ek.c |  2 +-
 board/atmel/sama5d2_ptc_ek/sama5d2_ptc_ek.c     | 12 ++++-----
 board/atmel/sama5d2_xplained/sama5d2_xplained.c |  2 +-
 drivers/gpio/atmel_pio4.c                       | 36 ++++++++++++-------------
 5 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/arch/arm/mach-at91/include/mach/atmel_pio4.h 
b/arch/arm/mach-at91/include/mach/atmel_pio4.h
index 6760bec..85d9ca4 100644
--- a/arch/arm/mach-at91/include/mach/atmel_pio4.h
+++ b/arch/arm/mach-at91/include/mach/atmel_pio4.h
@@ -69,14 +69,14 @@ struct atmel_pio4_port {
 #define AT91_PIO_PORTC         0x2
 #define AT91_PIO_PORTD         0x3
 
-int atmel_pio4_set_gpio(u32 port, u32 pin, u32 use_pullup);
-int atmel_pio4_set_a_periph(u32 port, u32 pin, u32 use_pullup);
-int atmel_pio4_set_b_periph(u32 port, u32 pin, u32 use_pullup);
-int atmel_pio4_set_c_periph(u32 port, u32 pin, u32 use_pullup);
-int atmel_pio4_set_d_periph(u32 port, u32 pin, u32 use_pullup);
-int atmel_pio4_set_e_periph(u32 port, u32 pin, u32 use_pullup);
-int atmel_pio4_set_f_periph(u32 port, u32 pin, u32 use_pullup);
-int atmel_pio4_set_g_periph(u32 port, u32 pin, u32 use_pullup);
+int atmel_pio4_set_gpio(u32 port, u32 pin, u32 config);
+int atmel_pio4_set_a_periph(u32 port, u32 pin, u32 config);
+int atmel_pio4_set_b_periph(u32 port, u32 pin, u32 config);
+int atmel_pio4_set_c_periph(u32 port, u32 pin, u32 config);
+int atmel_pio4_set_d_periph(u32 port, u32 pin, u32 config);
+int atmel_pio4_set_e_periph(u32 port, u32 pin, u32 config);
+int atmel_pio4_set_f_periph(u32 port, u32 pin, u32 config);
+int atmel_pio4_set_g_periph(u32 port, u32 pin, u32 config);
 int atmel_pio4_set_pio_output(u32 port, u32 pin, u32 value);
 int atmel_pio4_get_pio_input(u32 port, u32 pin);
 
diff --git a/board/atmel/sama5d27_som1_ek/sama5d27_som1_ek.c 
b/board/atmel/sama5d27_som1_ek/sama5d27_som1_ek.c
index 80d7725..4e3dc30 100644
--- a/board/atmel/sama5d27_som1_ek/sama5d27_som1_ek.c
+++ b/board/atmel/sama5d27_som1_ek/sama5d27_som1_ek.c
@@ -36,7 +36,7 @@ int board_late_init(void)
 #ifdef CONFIG_DEBUG_UART_BOARD_INIT
 static void board_uart1_hw_init(void)
 {
-       atmel_pio4_set_a_periph(AT91_PIO_PORTD, 2, 1);  /* URXD1 */
+       atmel_pio4_set_a_periph(AT91_PIO_PORTD, 2, ATMEL_PIO_PUEN_MASK);        
/* URXD1 */
        atmel_pio4_set_a_periph(AT91_PIO_PORTD, 3, 0);  /* UTXD1 */
 
        at91_periph_clk_enable(ATMEL_ID_UART1);
diff --git a/board/atmel/sama5d2_ptc_ek/sama5d2_ptc_ek.c 
b/board/atmel/sama5d2_ptc_ek/sama5d2_ptc_ek.c
index 4c2e209..ed1a637 100644
--- a/board/atmel/sama5d2_ptc_ek/sama5d2_ptc_ek.c
+++ b/board/atmel/sama5d2_ptc_ek/sama5d2_ptc_ek.c
@@ -59,22 +59,22 @@ static void board_nand_hw_init(void)
        atmel_pio4_set_b_periph(AT91_PIO_PORTA, 29, 0); /* D7 */
        atmel_pio4_set_b_periph(AT91_PIO_PORTB, 2, 0);  /* RE */
        atmel_pio4_set_b_periph(AT91_PIO_PORTA, 30, 0); /* WE */
-       atmel_pio4_set_b_periph(AT91_PIO_PORTA, 31, 1); /* NCS */
-       atmel_pio4_set_b_periph(AT91_PIO_PORTC, 8, 1);  /* RDY */
-       atmel_pio4_set_b_periph(AT91_PIO_PORTB, 0, 1);  /* ALE */
-       atmel_pio4_set_b_periph(AT91_PIO_PORTB, 1, 1);  /* CLE */
+       atmel_pio4_set_b_periph(AT91_PIO_PORTA, 31, ATMEL_PIO_PUEN_MASK);       
/* NCS */
+       atmel_pio4_set_b_periph(AT91_PIO_PORTC, 8, ATMEL_PIO_PUEN_MASK);        
/* RDY */
+       atmel_pio4_set_b_periph(AT91_PIO_PORTB, 0, ATMEL_PIO_PUEN_MASK);        
/* ALE */
+       atmel_pio4_set_b_periph(AT91_PIO_PORTB, 1, ATMEL_PIO_PUEN_MASK);        
/* CLE */
 }
 #endif
 
 static void board_usb_hw_init(void)
 {
-       atmel_pio4_set_pio_output(AT91_PIO_PORTB, 12, 1);
+       atmel_pio4_set_pio_output(AT91_PIO_PORTB, 12, ATMEL_PIO_PUEN_MASK);
 }
 
 #ifdef CONFIG_DEBUG_UART_BOARD_INIT
 static void board_uart0_hw_init(void)
 {
-       atmel_pio4_set_c_periph(AT91_PIO_PORTB, 26, 1); /* URXD0 */
+       atmel_pio4_set_c_periph(AT91_PIO_PORTB, 26, ATMEL_PIO_PUEN_MASK);       
/* URXD0 */
        atmel_pio4_set_c_periph(AT91_PIO_PORTB, 27, 0); /* UTXD0 */
 
        at91_periph_clk_enable(ATMEL_ID_UART0);
diff --git a/board/atmel/sama5d2_xplained/sama5d2_xplained.c 
b/board/atmel/sama5d2_xplained/sama5d2_xplained.c
index 778142a..0fac636 100644
--- a/board/atmel/sama5d2_xplained/sama5d2_xplained.c
+++ b/board/atmel/sama5d2_xplained/sama5d2_xplained.c
@@ -36,7 +36,7 @@ int board_late_init(void)
 #ifdef CONFIG_DEBUG_UART_BOARD_INIT
 static void board_uart1_hw_init(void)
 {
-       atmel_pio4_set_a_periph(AT91_PIO_PORTD, 2, 1);  /* URXD1 */
+       atmel_pio4_set_a_periph(AT91_PIO_PORTD, 2, ATMEL_PIO_PUEN_MASK);        
/* URXD1 */
        atmel_pio4_set_a_periph(AT91_PIO_PORTD, 3, 0);  /* UTXD1 */
 
        at91_periph_clk_enable(ATMEL_ID_UART1);
diff --git a/drivers/gpio/atmel_pio4.c b/drivers/gpio/atmel_pio4.c
index 30bc429..be4394c 100644
--- a/drivers/gpio/atmel_pio4.c
+++ b/drivers/gpio/atmel_pio4.c
@@ -44,7 +44,7 @@ static struct atmel_pio4_port *atmel_pio4_port_base(u32 port)
 }
 
 static int atmel_pio4_config_io_func(u32 port, u32 pin,
-                                    u32 func, u32 use_pullup)
+                                    u32 func, u32 config)
 {
        struct atmel_pio4_port *port_base;
        u32 reg, mask;
@@ -58,7 +58,7 @@ static int atmel_pio4_config_io_func(u32 port, u32 pin,
 
        mask = 1 << pin;
        reg = func;
-       reg |= use_pullup ? ATMEL_PIO_PUEN_MASK : 0;
+       reg |= config;
 
        writel(mask, &port_base->mskr);
        writel(reg, &port_base->cfgr);
@@ -66,60 +66,60 @@ static int atmel_pio4_config_io_func(u32 port, u32 pin,
        return 0;
 }
 
-int atmel_pio4_set_gpio(u32 port, u32 pin, u32 use_pullup)
+int atmel_pio4_set_gpio(u32 port, u32 pin, u32 config)
 {
        return atmel_pio4_config_io_func(port, pin,
                                         ATMEL_PIO_CFGR_FUNC_GPIO,
-                                        use_pullup);
+                                        config);
 }
 
-int atmel_pio4_set_a_periph(u32 port, u32 pin, u32 use_pullup)
+int atmel_pio4_set_a_periph(u32 port, u32 pin, u32 config)
 {
        return atmel_pio4_config_io_func(port, pin,
                                         ATMEL_PIO_CFGR_FUNC_PERIPH_A,
-                                        use_pullup);
+                                        config);
 }
 
-int atmel_pio4_set_b_periph(u32 port, u32 pin, u32 use_pullup)
+int atmel_pio4_set_b_periph(u32 port, u32 pin, u32 config)
 {
        return atmel_pio4_config_io_func(port, pin,
                                         ATMEL_PIO_CFGR_FUNC_PERIPH_B,
-                                        use_pullup);
+                                        config);
 }
 
-int atmel_pio4_set_c_periph(u32 port, u32 pin, u32 use_pullup)
+int atmel_pio4_set_c_periph(u32 port, u32 pin, u32 config)
 {
        return atmel_pio4_config_io_func(port, pin,
                                         ATMEL_PIO_CFGR_FUNC_PERIPH_C,
-                                        use_pullup);
+                                        config);
 }
 
-int atmel_pio4_set_d_periph(u32 port, u32 pin, u32 use_pullup)
+int atmel_pio4_set_d_periph(u32 port, u32 pin, u32 config)
 {
        return atmel_pio4_config_io_func(port, pin,
                                         ATMEL_PIO_CFGR_FUNC_PERIPH_D,
-                                        use_pullup);
+                                        config);
 }
 
-int atmel_pio4_set_e_periph(u32 port, u32 pin, u32 use_pullup)
+int atmel_pio4_set_e_periph(u32 port, u32 pin, u32 config)
 {
        return atmel_pio4_config_io_func(port, pin,
                                         ATMEL_PIO_CFGR_FUNC_PERIPH_E,
-                                        use_pullup);
+                                        config);
 }
 
-int atmel_pio4_set_f_periph(u32 port, u32 pin, u32 use_pullup)
+int atmel_pio4_set_f_periph(u32 port, u32 pin, u32 config)
 {
        return atmel_pio4_config_io_func(port, pin,
                                         ATMEL_PIO_CFGR_FUNC_PERIPH_F,
-                                        use_pullup);
+                                        config);
 }
 
-int atmel_pio4_set_g_periph(u32 port, u32 pin, u32 use_pullup)
+int atmel_pio4_set_g_periph(u32 port, u32 pin, u32 config)
 {
        return atmel_pio4_config_io_func(port, pin,
                                         ATMEL_PIO_CFGR_FUNC_PERIPH_G,
-                                        use_pullup);
+                                        config);
 }
 
 int atmel_pio4_set_pio_output(u32 port, u32 pin, u32 value)
-- 
2.7.4

_______________________________________________
U-Boot mailing list
[email protected]
https://lists.denx.de/listinfo/u-boot

Reply via email to