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