diff options
Diffstat (limited to 'firmware/target/arm/imx31/gigabeat-s/gpio-imx31.c')
-rw-r--r-- | firmware/target/arm/imx31/gigabeat-s/gpio-imx31.c | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/firmware/target/arm/imx31/gigabeat-s/gpio-imx31.c b/firmware/target/arm/imx31/gigabeat-s/gpio-imx31.c index a7427f16c0..0b76b84d36 100644 --- a/firmware/target/arm/imx31/gigabeat-s/gpio-imx31.c +++ b/firmware/target/arm/imx31/gigabeat-s/gpio-imx31.c | |||
@@ -44,7 +44,7 @@ extern const struct gpio_event_list gpio3_event_list; | |||
44 | 44 | ||
45 | static struct gpio_module_descriptor | 45 | static struct gpio_module_descriptor |
46 | { | 46 | { |
47 | volatile unsigned long *base; /* Module base address */ | 47 | struct gpio_map * const base; /* Module base address */ |
48 | enum IMX31_INT_LIST ints; /* AVIC int number */ | 48 | enum IMX31_INT_LIST ints; /* AVIC int number */ |
49 | void (*handler)(void); /* Interrupt function */ | 49 | void (*handler)(void); /* Interrupt function */ |
50 | const struct gpio_event_list *list; /* Event handler list */ | 50 | const struct gpio_event_list *list; /* Event handler list */ |
@@ -52,21 +52,21 @@ static struct gpio_module_descriptor | |||
52 | { | 52 | { |
53 | #if (GPIO_EVENT_MASK & USE_GPIO1_EVENTS) | 53 | #if (GPIO_EVENT_MASK & USE_GPIO1_EVENTS) |
54 | { | 54 | { |
55 | .base = (unsigned long *)GPIO1_BASE_ADDR, | 55 | .base = (struct gpio_map *)GPIO1_BASE_ADDR, |
56 | .ints = GPIO1, | 56 | .ints = GPIO1, |
57 | .handler = GPIO1_HANDLER, | 57 | .handler = GPIO1_HANDLER, |
58 | }, | 58 | }, |
59 | #endif | 59 | #endif |
60 | #if (GPIO_EVENT_MASK & USE_GPIO2_EVENTS) | 60 | #if (GPIO_EVENT_MASK & USE_GPIO2_EVENTS) |
61 | { | 61 | { |
62 | .base = (unsigned long *)GPIO2_BASE_ADDR, | 62 | .base = (struct gpio_map *)GPIO2_BASE_ADDR, |
63 | .ints = GPIO2, | 63 | .ints = GPIO2, |
64 | .handler = GPIO2_HANDLER, | 64 | .handler = GPIO2_HANDLER, |
65 | }, | 65 | }, |
66 | #endif | 66 | #endif |
67 | #if (GPIO_EVENT_MASK & USE_GPIO3_EVENTS) | 67 | #if (GPIO_EVENT_MASK & USE_GPIO3_EVENTS) |
68 | { | 68 | { |
69 | .base = (unsigned long *)GPIO3_BASE_ADDR, | 69 | .base = (struct gpio_map *)GPIO3_BASE_ADDR, |
70 | .ints = GPIO3, | 70 | .ints = GPIO3, |
71 | .handler = GPIO3_HANDLER, | 71 | .handler = GPIO3_HANDLER, |
72 | }, | 72 | }, |
@@ -77,17 +77,17 @@ static void gpio_call_events(enum gpio_module_number gpio) | |||
77 | { | 77 | { |
78 | const struct gpio_module_descriptor * const desc = &gpio_descs[gpio]; | 78 | const struct gpio_module_descriptor * const desc = &gpio_descs[gpio]; |
79 | const struct gpio_event_list * const list = desc->list; | 79 | const struct gpio_event_list * const list = desc->list; |
80 | volatile unsigned long * const base = desc->base; | 80 | struct gpio_map * const base = desc->base; |
81 | unsigned i; | 81 | unsigned i; |
82 | 82 | ||
83 | /* Intersect pending and unmasked bits */ | 83 | /* Intersect pending and unmasked bits */ |
84 | unsigned long pending = base[GPIO_ISR_I] & base[GPIO_IMR_I]; | 84 | uint32_t pending = base->isr & base->imr; |
85 | 85 | ||
86 | /* Call each event handler in order */ | 86 | /* Call each event handler in order */ |
87 | for (i = 0; i < list->count; i++) | 87 | for (i = 0; i < list->count; i++) |
88 | { | 88 | { |
89 | const struct gpio_event * const event = &list->events[i]; | 89 | const struct gpio_event * const event = &list->events[i]; |
90 | unsigned long bit = 1ul << event->line; | 90 | uint32_t bit = 1ul << event->line; |
91 | 91 | ||
92 | if ((pending & bit) && event->callback()) | 92 | if ((pending & bit) && event->callback()) |
93 | pending &= ~bit; | 93 | pending &= ~bit; |
@@ -144,10 +144,10 @@ bool gpio_enable_event(enum gpio_module_number gpio, unsigned id) | |||
144 | { | 144 | { |
145 | const struct gpio_module_descriptor * const desc = &gpio_descs[gpio]; | 145 | const struct gpio_module_descriptor * const desc = &gpio_descs[gpio]; |
146 | const struct gpio_event * const event = &desc->list->events[id]; | 146 | const struct gpio_event * const event = &desc->list->events[id]; |
147 | volatile unsigned long * const base = desc->base; | 147 | struct gpio_map * const base = desc->base; |
148 | volatile unsigned long * icr; | 148 | volatile uint32_t *icr; |
149 | unsigned long mask; | 149 | uint32_t mask; |
150 | unsigned long imr; | 150 | uint32_t imr; |
151 | int shift; | 151 | int shift; |
152 | 152 | ||
153 | if (id >= desc->list->count) | 153 | if (id >= desc->list->count) |
@@ -155,7 +155,7 @@ bool gpio_enable_event(enum gpio_module_number gpio, unsigned id) | |||
155 | 155 | ||
156 | int oldlevel = disable_irq_save(); | 156 | int oldlevel = disable_irq_save(); |
157 | 157 | ||
158 | imr = base[GPIO_IMR_I]; | 158 | imr = base->imr; |
159 | 159 | ||
160 | if (imr == 0) | 160 | if (imr == 0) |
161 | { | 161 | { |
@@ -165,14 +165,14 @@ bool gpio_enable_event(enum gpio_module_number gpio, unsigned id) | |||
165 | } | 165 | } |
166 | 166 | ||
167 | /* Set the line sense */ | 167 | /* Set the line sense */ |
168 | icr = &base[GPIO_ICR1_I] + event->line / 16; | 168 | icr = &base->icr[event->line >> 4]; |
169 | shift = 2*(event->line % 16); | 169 | shift = (event->line & 15) << 1; |
170 | mask = GPIO_SENSE_CONFIG_MASK << shift; | 170 | mask = GPIO_SENSE_CONFIG_MASK << shift; |
171 | 171 | ||
172 | *icr = (*icr & ~mask) | ((event->sense << shift) & mask); | 172 | *icr = (*icr & ~mask) | ((event->sense << shift) & mask); |
173 | 173 | ||
174 | /* Unmask the line */ | 174 | /* Unmask the line */ |
175 | base[GPIO_IMR_I] = imr | (1ul << event->line); | 175 | base->imr = imr | (1ul << event->line); |
176 | 176 | ||
177 | restore_irq(oldlevel); | 177 | restore_irq(oldlevel); |
178 | 178 | ||
@@ -183,8 +183,8 @@ void gpio_disable_event(enum gpio_module_number gpio, unsigned id) | |||
183 | { | 183 | { |
184 | const struct gpio_module_descriptor * const desc = &gpio_descs[gpio]; | 184 | const struct gpio_module_descriptor * const desc = &gpio_descs[gpio]; |
185 | const struct gpio_event * const event = &desc->list->events[id]; | 185 | const struct gpio_event * const event = &desc->list->events[id]; |
186 | volatile unsigned long * const base = desc->base; | 186 | struct gpio_map * const base = desc->base; |
187 | unsigned long imr; | 187 | uint32_t imr; |
188 | 188 | ||
189 | if (id >= desc->list->count) | 189 | if (id >= desc->list->count) |
190 | return; | 190 | return; |
@@ -192,10 +192,10 @@ void gpio_disable_event(enum gpio_module_number gpio, unsigned id) | |||
192 | int oldlevel = disable_irq_save(); | 192 | int oldlevel = disable_irq_save(); |
193 | 193 | ||
194 | /* Remove bit from mask */ | 194 | /* Remove bit from mask */ |
195 | imr = base[GPIO_IMR_I] & ~(1ul << event->line); | 195 | imr = base->imr & ~(1ul << event->line); |
196 | 196 | ||
197 | /* Mask the line */ | 197 | /* Mask the line */ |
198 | base[GPIO_IMR_I] = imr; | 198 | base->imr = imr; |
199 | 199 | ||
200 | if (imr == 0) | 200 | if (imr == 0) |
201 | { | 201 | { |