summaryrefslogtreecommitdiff
path: root/firmware/target/arm/imx31/gigabeat-s/gpio-imx31.h
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/imx31/gigabeat-s/gpio-imx31.h')
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/gpio-imx31.h56
1 files changed, 40 insertions, 16 deletions
diff --git a/firmware/target/arm/imx31/gigabeat-s/gpio-imx31.h b/firmware/target/arm/imx31/gigabeat-s/gpio-imx31.h
index 34d3e72f8e..c3c3e1f63b 100644
--- a/firmware/target/arm/imx31/gigabeat-s/gpio-imx31.h
+++ b/firmware/target/arm/imx31/gigabeat-s/gpio-imx31.h
@@ -19,12 +19,12 @@
19#ifndef GPIO_IMX31_H 19#ifndef GPIO_IMX31_H
20#define GPIO_IMX31_H 20#define GPIO_IMX31_H
21 21
22#include "gpio-target.h" 22/* Static registration mechanism for imx31 GPIO interrupts */
23
24#define USE_GPIO1_EVENTS (1 << 0) 23#define USE_GPIO1_EVENTS (1 << 0)
25#define USE_GPIO2_EVENTS (1 << 1) 24#define USE_GPIO2_EVENTS (1 << 1)
26#define USE_GPIO3_EVENTS (1 << 2) 25#define USE_GPIO3_EVENTS (1 << 2)
27 26
27/* Module indexes defined by which GPIO modules are used */
28enum gpio_module_number 28enum gpio_module_number
29{ 29{
30 __GPIO_NUM_START = -1, 30 __GPIO_NUM_START = -1,
@@ -40,6 +40,22 @@ enum gpio_module_number
40 GPIO_NUM_GPIO, 40 GPIO_NUM_GPIO,
41}; 41};
42 42
43/* Module corresponding to the event ID is identified by range */
44enum gpio_event_bases
45{
46#if (GPIO_EVENT_MASK & USE_GPIO1_EVENTS)
47 GPIO1_EVENT_FIRST = 32*GPIO1_NUM,
48#endif
49#if (GPIO_EVENT_MASK & USE_GPIO2_EVENTS)
50 GPIO2_EVENT_FIRST = 32*GPIO2_NUM,
51#endif
52#if (GPIO_EVENT_MASK & USE_GPIO3_EVENTS)
53 GPIO3_EVENT_FIRST = 32*GPIO3_NUM,
54#endif
55};
56
57#include "gpio-target.h"
58
43/* Possible values for gpio interrupt line config */ 59/* Possible values for gpio interrupt line config */
44enum gpio_int_sense_enum 60enum gpio_int_sense_enum
45{ 61{
@@ -54,35 +70,43 @@ enum gpio_int_sense_enum
54/* Register map for each module */ 70/* Register map for each module */
55struct gpio_map 71struct gpio_map
56{ 72{
57 volatile uint32_t dr; /* 00h */ 73 volatile uint32_t dr; /* 00h */
58 volatile uint32_t gdir; /* 04h */ 74 volatile uint32_t gdir; /* 04h */
59 volatile uint32_t psr; /* 08h */ 75 volatile uint32_t psr; /* 08h */
60 volatile uint32_t icr[2]; /* 0Ch */ 76 union
61 volatile uint32_t imr; /* 14h */ 77 {
62 volatile uint32_t isr; /* 18h */ 78 struct
79 {
80 volatile uint32_t icr1; /* 0Ch */
81 volatile uint32_t icr2; /* 10h */
82 };
83 volatile uint32_t icr[2]; /* 0Ch */
84 };
85 volatile uint32_t imr; /* 14h */
86 volatile uint32_t isr; /* 18h */
63}; 87};
64 88
65/* Pending events will be called in array order */ 89/* Pending events will be called in array order which allows easy
90 * pioritization */
66 91
67/* Describes a single event for a pin */ 92/* Describes a single event for a pin */
68struct gpio_event 93struct gpio_event
69{ 94{
70 int line; /* Line number (0-31) */ 95 uint32_t mask; /* mask: 1 << (0...31) */
71 enum gpio_int_sense_enum sense; /* Type of sense */ 96 enum gpio_int_sense_enum sense; /* Type of sense */
72 int (*callback)(void); /* Callback function (return nonzero 97 void (*callback)(void); /* Callback function */
73 * to indicate this event was handled) */
74}; 98};
75 99
76/* Describes the events attached to a port */ 100/* Describes the events attached to a port */
77struct gpio_event_list 101struct gpio_event_list
78{ 102{
79 int priority; /* Interrupt priority for this GPIO */ 103 int ints_priority; /* Interrupt priority for this GPIO */
80 unsigned count; /* Count of events */ 104 unsigned count; /* Count of events for the module */
81 const struct gpio_event *events; /* List of events */ 105 const struct gpio_event *events; /* List of events */
82}; 106};
83 107
84void gpio_init(void); 108void gpio_init(void);
85bool gpio_enable_event(enum gpio_module_number gpio, unsigned id); 109bool gpio_enable_event(enum gpio_event_ids id);
86void gpio_disable_event(enum gpio_module_number gpio, unsigned id); 110void gpio_disable_event(enum gpio_event_ids id);
87 111
88#endif /* GPIO_IMX31_H */ 112#endif /* GPIO_IMX31_H */