summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBo Shen <voice.shen@atmel.com>2013-08-13 14:38:31 +0800
committerAndreas Bießmann <andreas.devel@googlemail.com>2013-08-22 16:51:33 +0200
commit6edaea8705c19d2b89e941efcb4257a01fd9725e (patch)
tree03f908c920e7cefa3c02171f82dec6b5a5c3d382
parent4bc9b7a56036f7ecf402842e5c381c0ed3bdca4c (diff)
gpio: atmel: add gpio common API support
add gpio common API support for gpio command Signed-off-by: Bo Shen <voice.shen@atmel.com> [fix unnecessary cast] Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com>
-rw-r--r--drivers/gpio/at91_gpio.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/drivers/gpio/at91_gpio.c b/drivers/gpio/at91_gpio.c
index 6d227d36fe..6073843b5e 100644
--- a/drivers/gpio/at91_gpio.c
+++ b/drivers/gpio/at91_gpio.c
@@ -353,3 +353,46 @@ int at91_get_pio_value(unsigned port, unsigned pin)
return pdsr != 0;
}
+
+/* Common GPIO API */
+
+#define at91_gpio_to_port(gpio) (gpio / 32)
+#define at91_gpio_to_pin(gpio) (gpio % 32)
+
+int gpio_request(unsigned gpio, const char *label)
+{
+ return 0;
+}
+
+int gpio_free(unsigned gpio)
+{
+ return 0;
+}
+
+int gpio_direction_input(unsigned gpio)
+{
+ at91_set_pio_input(at91_gpio_to_port(gpio),
+ at91_gpio_to_pin(gpio), 0);
+ return 0;
+}
+
+int gpio_direction_output(unsigned gpio, int value)
+{
+ at91_set_pio_output(at91_gpio_to_port(gpio),
+ at91_gpio_to_pin(gpio), value);
+ return 0;
+}
+
+int gpio_get_value(unsigned gpio)
+{
+ return at91_get_pio_value(at91_gpio_to_port(gpio),
+ at91_gpio_to_pin(gpio));
+}
+
+int gpio_set_value(unsigned gpio, int value)
+{
+ at91_set_pio_value(at91_gpio_to_port(gpio),
+ at91_gpio_to_pin(gpio), value);
+
+ return 0;
+}