Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 137374
b: refs/heads/master
c: 28d27cf
h: refs/heads/master
v: v3
  • Loading branch information
Nicolas Pitre committed Feb 20, 2009
1 parent aff6635 commit c3cfe45
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 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: 22fc1db12515e1b528570c547fd27e38df792f1f
refs/heads/master: 28d27cf4ce8378180eda32aa7d8e778c9e72a54f
29 changes: 20 additions & 9 deletions trunk/arch/arm/plat-orion/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

static DEFINE_SPINLOCK(gpio_lock);
static const char *gpio_label[GPIO_MAX]; /* non null for allocated GPIOs */
static unsigned long gpio_valid[BITS_TO_LONGS(GPIO_MAX)];
static unsigned long gpio_valid_input[BITS_TO_LONGS(GPIO_MAX)];
static unsigned long gpio_valid_output[BITS_TO_LONGS(GPIO_MAX)];

static inline void __set_direction(unsigned pin, int input)
{
Expand Down Expand Up @@ -53,7 +54,7 @@ int gpio_direction_input(unsigned pin)
{
unsigned long flags;

if (pin >= GPIO_MAX || !test_bit(pin, gpio_valid)) {
if (pin >= GPIO_MAX || !test_bit(pin, gpio_valid_input)) {
pr_debug("%s: invalid GPIO %d\n", __func__, pin);
return -EINVAL;
}
Expand Down Expand Up @@ -83,7 +84,7 @@ int gpio_direction_output(unsigned pin, int value)
unsigned long flags;
u32 u;

if (pin >= GPIO_MAX || !test_bit(pin, gpio_valid)) {
if (pin >= GPIO_MAX || !test_bit(pin, gpio_valid_output)) {
pr_debug("%s: invalid GPIO %d\n", __func__, pin);
return -EINVAL;
}
Expand Down Expand Up @@ -161,7 +162,9 @@ int gpio_request(unsigned pin, const char *label)
unsigned long flags;
int ret;

if (pin >= GPIO_MAX || !test_bit(pin, gpio_valid)) {
if (pin >= GPIO_MAX ||
!(test_bit(pin, gpio_valid_input) ||
test_bit(pin, gpio_valid_output))) {
pr_debug("%s: invalid GPIO %d\n", __func__, pin);
return -EINVAL;
}
Expand All @@ -183,7 +186,9 @@ EXPORT_SYMBOL(gpio_request);

void gpio_free(unsigned pin)
{
if (pin >= GPIO_MAX || !test_bit(pin, gpio_valid)) {
if (pin >= GPIO_MAX ||
!(test_bit(pin, gpio_valid_input) ||
test_bit(pin, gpio_valid_output))) {
pr_debug("%s: invalid GPIO %d\n", __func__, pin);
return;
}
Expand All @@ -208,12 +213,18 @@ void __init orion_gpio_set_unused(unsigned pin)
__set_direction(pin, 0);
}

void __init orion_gpio_set_valid(unsigned pin, int valid)
void __init orion_gpio_set_valid(unsigned pin, int mode)
{
if (valid)
__set_bit(pin, gpio_valid);
if (mode == 1)
mode = GPIO_INPUT_OK | GPIO_OUTPUT_OK;
if (mode & GPIO_INPUT_OK)
__set_bit(pin, gpio_valid_input);
else
__clear_bit(pin, gpio_valid);
__clear_bit(pin, gpio_valid_input);
if (mode & GPIO_OUTPUT_OK)
__set_bit(pin, gpio_valid_output);
else
__clear_bit(pin, gpio_valid_output);
}

void orion_gpio_set_blink(unsigned pin, int blink)
Expand Down
6 changes: 5 additions & 1 deletion trunk/arch/arm/plat-orion/include/plat/gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@ void gpio_set_value(unsigned pin, int value);
* Orion-specific GPIO API extensions.
*/
void orion_gpio_set_unused(unsigned pin);
void orion_gpio_set_valid(unsigned pin, int valid);
void orion_gpio_set_blink(unsigned pin, int blink);

#define GPIO_BIDI_OK (1 << 0)
#define GPIO_INPUT_OK (1 << 1)
#define GPIO_OUTPUT_OK (1 << 2)
void orion_gpio_set_valid(unsigned pin, int mode);

/*
* GPIO interrupt handling.
*/
Expand Down

0 comments on commit c3cfe45

Please sign in to comment.