Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 47956
b: refs/heads/master
c: a31c4ee
h: refs/heads/master
v: v3
  • Loading branch information
David Brownell authored and Linus Torvalds committed Feb 12, 2007
1 parent 3ea21ed commit 7289f81
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3c729f1ecd23b86a2d6b211d646f57f9da8dfeb1
refs/heads/master: a31c4eea2127ee52b5c7c1befada4664963ad030
48 changes: 48 additions & 0 deletions trunk/arch/arm/mach-at91rm9200/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,24 @@ static inline unsigned pin_to_mask(unsigned pin)
*/


/*
* mux the pin to the "GPIO" peripheral role.
*/
int __init_or_module at91_set_GPIO_periph(unsigned pin, int use_pullup)
{
void __iomem *pio = pin_to_controller(pin);
unsigned mask = pin_to_mask(pin);

if (!pio)
return -EINVAL;
__raw_writel(mask, pio + PIO_IDR);
__raw_writel(mask, pio + (use_pullup ? PIO_PUER : PIO_PUDR));
__raw_writel(mask, pio + PIO_PER);
return 0;
}
EXPORT_SYMBOL(at91_set_GPIO_periph);


/*
* mux the pin to the "A" internal peripheral role.
*/
Expand Down Expand Up @@ -181,6 +199,36 @@ EXPORT_SYMBOL(at91_set_multi_drive);

/*--------------------------------------------------------------------------*/

/* new-style GPIO calls; these expect at91_set_GPIO_periph to have been
* called, and maybe at91_set_multi_drive() for putout pins.
*/

int gpio_direction_input(unsigned pin)
{
void __iomem *pio = pin_to_controller(pin);
unsigned mask = pin_to_mask(pin);

if (!pio || !(__raw_readl(pio + PIO_PSR) & mask))
return -EINVAL;
__raw_writel(mask, pio + PIO_OER);
return 0;
}
EXPORT_SYMBOL(gpio_direction_input);

int gpio_direction_output(unsigned pin)
{
void __iomem *pio = pin_to_controller(pin);
unsigned mask = pin_to_mask(pin);

if (!pio || !(__raw_readl(pio + PIO_PSR) & mask))
return -EINVAL;
__raw_writel(mask, pio + PIO_OER);
return 0;
}
EXPORT_SYMBOL(gpio_direction_output);

/*--------------------------------------------------------------------------*/

/*
* assuming the pin is muxed as a gpio output, set its value.
*/
Expand Down
48 changes: 46 additions & 2 deletions trunk/include/asm-arm/arch-at91rm9200/gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@

#ifndef __ASSEMBLY__
/* setup setup routines, called from board init or driver probe() */
extern int __init_or_module at91_set_GPIO_periph(unsigned pin, int use_pullup);
extern int __init_or_module at91_set_A_periph(unsigned pin, int use_pullup);
extern int __init_or_module at91_set_B_periph(unsigned pin, int use_pullup);
extern int __init_or_module at91_set_gpio_input(unsigned pin, int use_pullup);
Expand All @@ -193,7 +194,50 @@ extern int at91_get_gpio_value(unsigned pin);
/* callable only from core power-management code */
extern void at91_gpio_suspend(void);
extern void at91_gpio_resume(void);
#endif

#endif
/*-------------------------------------------------------------------------*/

/* wrappers for "new style" GPIO calls. the old AT91-specfic ones should
* eventually be removed (along with this errno.h inclusion), and the
* gpio request/free calls should probably be implemented.
*/

#include <asm/errno.h>

static inline int gpio_request(unsigned gpio, const char *label)
{
return 0;
}

static inline void gpio_free(unsigned gpio)
{
}

extern int gpio_direction_input(unsigned gpio);
extern int gpio_direction_output(unsigned gpio);

static inline int gpio_get_value(unsigned gpio)
{
return at91_get_gpio_value(gpio);
}

static inline void gpio_set_value(unsigned gpio, int value)
{
at91_set_gpio_value(gpio, value);
}

#include <asm-generic/gpio.h> /* cansleep wrappers */

static inline int gpio_to_irq(unsigned gpio)
{
return gpio;
}

static inline int irq_to_gpio(unsigned irq)
{
return irq;
}

#endif /* __ASSEMBLY__ */

#endif

0 comments on commit 7289f81

Please sign in to comment.