diff options
Diffstat (limited to 'firmware/target/arm/imx31/gigabeat-s/gpio-imx31.h')
-rw-r--r-- | firmware/target/arm/imx31/gigabeat-s/gpio-imx31.h | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/firmware/target/arm/imx31/gigabeat-s/gpio-imx31.h b/firmware/target/arm/imx31/gigabeat-s/gpio-imx31.h new file mode 100644 index 0000000000..a197558ad4 --- /dev/null +++ b/firmware/target/arm/imx31/gigabeat-s/gpio-imx31.h | |||
@@ -0,0 +1,77 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (c) 2008 by Michael Sevakis | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #ifndef _GPIO_IMX31_H_ | ||
20 | #define _GPIO_IMX31_H_ | ||
21 | |||
22 | #include "gpio-target.h" | ||
23 | |||
24 | #define USE_GPIO1_EVENTS (1 << 0) | ||
25 | #define USE_GPIO2_EVENTS (1 << 1) | ||
26 | #define USE_GPIO3_EVENTS (1 << 2) | ||
27 | |||
28 | enum gpio_module_number | ||
29 | { | ||
30 | __GPIO_NUM_START = -1, | ||
31 | #if (GPIO_EVENT_MASK & USE_GPIO1_EVENTS) | ||
32 | GPIO1_NUM, | ||
33 | #endif | ||
34 | #if (GPIO_EVENT_MASK & USE_GPIO2_EVENTS) | ||
35 | GPIO2_NUM, | ||
36 | #endif | ||
37 | #if (GPIO_EVENT_MASK & USE_GPIO3_EVENTS) | ||
38 | GPIO3_NUM, | ||
39 | #endif | ||
40 | GPIO_NUM_GPIO, | ||
41 | }; | ||
42 | |||
43 | /* Possible values for gpio interrupt line config */ | ||
44 | enum gpio_int_sense_enum | ||
45 | { | ||
46 | GPIO_SENSE_LOW_LEVEL = 0, /* High-level sensitive */ | ||
47 | GPIO_SENSE_HIGH_LEVEL, /* Low-level sensitive */ | ||
48 | GPIO_SENSE_RISING, /* Rising-edge sensitive */ | ||
49 | GPIO_SENSE_FALLING, /* Falling-edge sensitive */ | ||
50 | }; | ||
51 | |||
52 | #define GPIO_SENSE_CONFIG_MASK 0x3 | ||
53 | |||
54 | /* Pending events will be called in array order */ | ||
55 | |||
56 | /* Describes a single event for a pin */ | ||
57 | struct gpio_event | ||
58 | { | ||
59 | int line; /* Line number (0-31) */ | ||
60 | enum gpio_int_sense_enum sense; /* Type of sense */ | ||
61 | int (*callback)(void); /* Callback function (return nonzero | ||
62 | * to indicate this event was handled) */ | ||
63 | }; | ||
64 | |||
65 | /* Describes the events attached to a port */ | ||
66 | struct gpio_event_list | ||
67 | { | ||
68 | int priority; /* Interrupt priority for this GPIO */ | ||
69 | unsigned count; /* Count of events */ | ||
70 | const struct gpio_event *events; /* List of events */ | ||
71 | }; | ||
72 | |||
73 | void gpio_init(void); | ||
74 | bool gpio_enable_event(enum gpio_module_number gpio, unsigned id); | ||
75 | void gpio_disable_event(enum gpio_module_number gpio, unsigned id); | ||
76 | |||
77 | #endif /* _GPIO_IMX31_H_ */ | ||