Message ID | 1471418009-12660-6-git-send-email-hs@denx.de |
---|---|
State | Changes Requested |
Delegated to: | Andreas Bießmann |
Headers | show |
> -----Original Message----- > From: U-Boot [mailto:u-boot-bounces@lists.denx.de] On Behalf Of Heiko > Schocher > Sent: 2016年8月17日 15:13 > To: U-Boot Mailing List <u-boot@lists.denx.de> > Cc: Bo Shen <voice.shen@atmel.com> > Subject: [U-Boot] [PATCH 5/6] at91: add function to set IO drive > > add new function to set I/O drive. > > Signed-off-by: Heiko Schocher <hs@denx.de> Acked-by: Wenyou Yang <wenyou.yang@atmel.com> > --- > > arch/arm/mach-at91/include/mach/at91_pio.h | 5 +++++ > arch/arm/mach-at91/include/mach/gpio.h | 2 ++ > drivers/gpio/at91_gpio.c | 29 +++++++++++++++++++++++++++++ > 3 files changed, 36 insertions(+) > > diff --git a/arch/arm/mach-at91/include/mach/at91_pio.h b/arch/arm/mach- > at91/include/mach/at91_pio.h > index 8e054e1..535208a 100644 > --- a/arch/arm/mach-at91/include/mach/at91_pio.h > +++ b/arch/arm/mach-at91/include/mach/at91_pio.h > @@ -134,6 +134,7 @@ int at91_set_pio_debounce(unsigned port, unsigned pin, > int is_on, int div); int at91_set_pio_pulldown(unsigned port, unsigned pin, int > is_on); int at91_set_pio_disable_schmitt_trig(unsigned port, unsigned pin); > #endif > +int at91_set_pio_io_drive(unsigned port, unsigned pin, int value); > int at91_set_pio_input(unsigned port, unsigned pin, int use_pullup); int > at91_set_pio_multi_drive(unsigned port, unsigned pin, int is_on); int > at91_set_pio_output(unsigned port, unsigned pin, int value); @@ -151,4 +152,8 > @@ int at91_get_pio_value(unsigned port, unsigned pin); > #define AT91_PIO_PORTD 0x3 > #define AT91_PIO_PORTE 0x4 > > +/* allowed I/O driver values */ > +#define AT91_PIO_HI_DRIVE 0 > +#define AT91_PIO_MEDIUM_DRIVE 1 > +#define AT91_PIO_LOW_DRIVE 2 > #endif > diff --git a/arch/arm/mach-at91/include/mach/gpio.h b/arch/arm/mach- > at91/include/mach/gpio.h > index 6d2a7b7..2b89309 100644 > --- a/arch/arm/mach-at91/include/mach/gpio.h > +++ b/arch/arm/mach-at91/include/mach/gpio.h > @@ -227,6 +227,8 @@ static inline unsigned pin_to_mask(unsigned pin) > at91_set_pio_value((x - PIN_BASE) / 32,(x % 32), y) #define > at91_get_gpio_value(x) \ > at91_get_pio_value((x - PIN_BASE) / 32,(x % 32)) > +#define at91_set_gpio_io_drive(x, v) \ > + at91_set_pio_io_drive((x - PIN_BASE) / 32,(x % 32), v) > #else > #define at91_set_gpio_value(x, y) at91_set_pio_value(x, y) > #define at91_get_gpio_value(x) at91_get_pio_value(x) > diff --git a/drivers/gpio/at91_gpio.c b/drivers/gpio/at91_gpio.c index > 8e52e3d..1f624f8 100644 > --- a/drivers/gpio/at91_gpio.c > +++ b/drivers/gpio/at91_gpio.c > @@ -358,6 +358,35 @@ int at91_set_pio_multi_drive(unsigned port, unsigned pin, > int is_on) > return 0; > } > > +#if defined(CPU_HAS_PIO3) > +/* > + * set I/O driver value > + */ > +int at91_set_pio_io_drive(unsigned port, unsigned pin, int value) { > + struct at91_port *at91_port = at91_pio_get_port(port); > + u32 *reg; > + u32 mask; > + > + if (pin > 15) { > + reg = &at91_port->io_driver2; > + pin -= 16; > + } else { > + reg = &at91_port->io_driver1; > + } > + > + mask = 0x3 << (pin * 2); > + clrsetbits_le32(reg, mask, value << (pin * 2)); > + return 0; > +} > +#else > +int at91_set_pio_io_drive(unsigned port, unsigned pin, int value) { > + return -ENOENT; > +} > +#endif > + > + > static void at91_set_port_value(struct at91_port *at91_port, int offset, > int value) > { > -- > 2.5.5 > > _______________________________________________ > U-Boot mailing list > U-Boot@lists.denx.de > http://lists.denx.de/mailman/listinfo/u-boot
On 17.08.16 09:13, Heiko Schocher wrote: > add new function to set I/O drive. > > Signed-off-by: Heiko Schocher <hs@denx.de> > --- > > arch/arm/mach-at91/include/mach/at91_pio.h | 5 +++++ > arch/arm/mach-at91/include/mach/gpio.h | 2 ++ > drivers/gpio/at91_gpio.c | 29 +++++++++++++++++++++++++++++ > 3 files changed, 36 insertions(+) > > diff --git a/arch/arm/mach-at91/include/mach/at91_pio.h b/arch/arm/mach-at91/include/mach/at91_pio.h > index 8e054e1..535208a 100644 > --- a/arch/arm/mach-at91/include/mach/at91_pio.h > +++ b/arch/arm/mach-at91/include/mach/at91_pio.h > @@ -134,6 +134,7 @@ int at91_set_pio_debounce(unsigned port, unsigned pin, int is_on, int div); > int at91_set_pio_pulldown(unsigned port, unsigned pin, int is_on); > int at91_set_pio_disable_schmitt_trig(unsigned port, unsigned pin); > #endif > +int at91_set_pio_io_drive(unsigned port, unsigned pin, int value); > int at91_set_pio_input(unsigned port, unsigned pin, int use_pullup); > int at91_set_pio_multi_drive(unsigned port, unsigned pin, int is_on); > int at91_set_pio_output(unsigned port, unsigned pin, int value); > @@ -151,4 +152,8 @@ int at91_get_pio_value(unsigned port, unsigned pin); > #define AT91_PIO_PORTD 0x3 > #define AT91_PIO_PORTE 0x4 > > +/* allowed I/O driver values */ > +#define AT91_PIO_HI_DRIVE 0 sama5 has 0 + 1 low drive, 2 medium and 3 hi :( > +#define AT91_PIO_MEDIUM_DRIVE 1 > +#define AT91_PIO_LOW_DRIVE 2 > #endif > diff --git a/arch/arm/mach-at91/include/mach/gpio.h b/arch/arm/mach-at91/include/mach/gpio.h > index 6d2a7b7..2b89309 100644 > --- a/arch/arm/mach-at91/include/mach/gpio.h > +++ b/arch/arm/mach-at91/include/mach/gpio.h > @@ -227,6 +227,8 @@ static inline unsigned pin_to_mask(unsigned pin) > at91_set_pio_value((x - PIN_BASE) / 32,(x % 32), y) > #define at91_get_gpio_value(x) \ > at91_get_pio_value((x - PIN_BASE) / 32,(x % 32)) > +#define at91_set_gpio_io_drive(x, v) \ > + at91_set_pio_io_drive((x - PIN_BASE) / 32,(x % 32), v) > #else > #define at91_set_gpio_value(x, y) at91_set_pio_value(x, y) > #define at91_get_gpio_value(x) at91_get_pio_value(x) > diff --git a/drivers/gpio/at91_gpio.c b/drivers/gpio/at91_gpio.c > index 8e52e3d..1f624f8 100644 > --- a/drivers/gpio/at91_gpio.c > +++ b/drivers/gpio/at91_gpio.c > @@ -358,6 +358,35 @@ int at91_set_pio_multi_drive(unsigned port, unsigned pin, int is_on) > return 0; > } > > +#if defined(CPU_HAS_PIO3) > +/* > + * set I/O driver value > + */ > +int at91_set_pio_io_drive(unsigned port, unsigned pin, int value) > +{ > + struct at91_port *at91_port = at91_pio_get_port(port); > + u32 *reg; > + u32 mask; > + > + if (pin > 15) { > + reg = &at91_port->io_driver2; > + pin -= 16; > + } else { > + reg = &at91_port->io_driver1; > + } > + > + mask = 0x3 << (pin * 2); > + clrsetbits_le32(reg, mask, value << (pin * 2)); > + return 0; > +} > +#else > +int at91_set_pio_io_drive(unsigned port, unsigned pin, int value) > +{ > + return -ENOENT; > +} > +#endif > + > + > static void at91_set_port_value(struct at91_port *at91_port, int offset, > int value) > { >
diff --git a/arch/arm/mach-at91/include/mach/at91_pio.h b/arch/arm/mach-at91/include/mach/at91_pio.h index 8e054e1..535208a 100644 --- a/arch/arm/mach-at91/include/mach/at91_pio.h +++ b/arch/arm/mach-at91/include/mach/at91_pio.h @@ -134,6 +134,7 @@ int at91_set_pio_debounce(unsigned port, unsigned pin, int is_on, int div); int at91_set_pio_pulldown(unsigned port, unsigned pin, int is_on); int at91_set_pio_disable_schmitt_trig(unsigned port, unsigned pin); #endif +int at91_set_pio_io_drive(unsigned port, unsigned pin, int value); int at91_set_pio_input(unsigned port, unsigned pin, int use_pullup); int at91_set_pio_multi_drive(unsigned port, unsigned pin, int is_on); int at91_set_pio_output(unsigned port, unsigned pin, int value); @@ -151,4 +152,8 @@ int at91_get_pio_value(unsigned port, unsigned pin); #define AT91_PIO_PORTD 0x3 #define AT91_PIO_PORTE 0x4 +/* allowed I/O driver values */ +#define AT91_PIO_HI_DRIVE 0 +#define AT91_PIO_MEDIUM_DRIVE 1 +#define AT91_PIO_LOW_DRIVE 2 #endif diff --git a/arch/arm/mach-at91/include/mach/gpio.h b/arch/arm/mach-at91/include/mach/gpio.h index 6d2a7b7..2b89309 100644 --- a/arch/arm/mach-at91/include/mach/gpio.h +++ b/arch/arm/mach-at91/include/mach/gpio.h @@ -227,6 +227,8 @@ static inline unsigned pin_to_mask(unsigned pin) at91_set_pio_value((x - PIN_BASE) / 32,(x % 32), y) #define at91_get_gpio_value(x) \ at91_get_pio_value((x - PIN_BASE) / 32,(x % 32)) +#define at91_set_gpio_io_drive(x, v) \ + at91_set_pio_io_drive((x - PIN_BASE) / 32,(x % 32), v) #else #define at91_set_gpio_value(x, y) at91_set_pio_value(x, y) #define at91_get_gpio_value(x) at91_get_pio_value(x) diff --git a/drivers/gpio/at91_gpio.c b/drivers/gpio/at91_gpio.c index 8e52e3d..1f624f8 100644 --- a/drivers/gpio/at91_gpio.c +++ b/drivers/gpio/at91_gpio.c @@ -358,6 +358,35 @@ int at91_set_pio_multi_drive(unsigned port, unsigned pin, int is_on) return 0; } +#if defined(CPU_HAS_PIO3) +/* + * set I/O driver value + */ +int at91_set_pio_io_drive(unsigned port, unsigned pin, int value) +{ + struct at91_port *at91_port = at91_pio_get_port(port); + u32 *reg; + u32 mask; + + if (pin > 15) { + reg = &at91_port->io_driver2; + pin -= 16; + } else { + reg = &at91_port->io_driver1; + } + + mask = 0x3 << (pin * 2); + clrsetbits_le32(reg, mask, value << (pin * 2)); + return 0; +} +#else +int at91_set_pio_io_drive(unsigned port, unsigned pin, int value) +{ + return -ENOENT; +} +#endif + + static void at91_set_port_value(struct at91_port *at91_port, int offset, int value) {
add new function to set I/O drive. Signed-off-by: Heiko Schocher <hs@denx.de> --- arch/arm/mach-at91/include/mach/at91_pio.h | 5 +++++ arch/arm/mach-at91/include/mach/gpio.h | 2 ++ drivers/gpio/at91_gpio.c | 29 +++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+)