diff options
author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
---|---|---|
committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
commit | fcc9d2e5a6c89d22b8b773a64fb4ad21ac318446 (patch) | |
tree | a57612d1888735a2ec7972891b68c1ac5ec8faea /arch/arm/mach-sa1100 | |
parent | 8dea78da5cee153b8af9c07a2745f6c55057fe12 (diff) |
Diffstat (limited to 'arch/arm/mach-sa1100')
-rw-r--r-- | arch/arm/mach-sa1100/dma.c | 348 | ||||
-rw-r--r-- | arch/arm/mach-sa1100/gpio.c | 65 | ||||
-rw-r--r-- | arch/arm/mach-sa1100/include/mach/SA-1111.h | 5 | ||||
-rw-r--r-- | arch/arm/mach-sa1100/include/mach/dma.h | 117 | ||||
-rw-r--r-- | arch/arm/mach-sa1100/include/mach/io.h | 22 | ||||
-rw-r--r-- | arch/arm/mach-sa1100/include/mach/lart.h | 13 | ||||
-rw-r--r-- | arch/arm/mach-sa1100/include/mach/mcp.h | 22 | ||||
-rw-r--r-- | arch/arm/mach-sa1100/include/mach/system.h | 22 | ||||
-rw-r--r-- | arch/arm/mach-sa1100/include/mach/vmalloc.h | 4 | ||||
-rw-r--r-- | arch/arm/mach-sa1100/leds-assabet.c | 114 | ||||
-rw-r--r-- | arch/arm/mach-sa1100/leds-badge4.c | 111 | ||||
-rw-r--r-- | arch/arm/mach-sa1100/leds-cerf.c | 110 | ||||
-rw-r--r-- | arch/arm/mach-sa1100/leds-hackkit.c | 112 | ||||
-rw-r--r-- | arch/arm/mach-sa1100/leds-lart.c | 101 | ||||
-rw-r--r-- | arch/arm/mach-sa1100/leds-simpad.c | 100 | ||||
-rw-r--r-- | arch/arm/mach-sa1100/leds.c | 52 | ||||
-rw-r--r-- | arch/arm/mach-sa1100/leds.h | 14 |
17 files changed, 1332 insertions, 0 deletions
diff --git a/arch/arm/mach-sa1100/dma.c b/arch/arm/mach-sa1100/dma.c new file mode 100644 index 00000000000..ad660350c29 --- /dev/null +++ b/arch/arm/mach-sa1100/dma.c | |||
@@ -0,0 +1,348 @@ | |||
1 | /* | ||
2 | * arch/arm/mach-sa1100/dma.c | ||
3 | * | ||
4 | * Support functions for the SA11x0 internal DMA channels. | ||
5 | * | ||
6 | * Copyright (C) 2000, 2001 by Nicolas Pitre | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | */ | ||
12 | |||
13 | #include <linux/module.h> | ||
14 | #include <linux/interrupt.h> | ||
15 | #include <linux/init.h> | ||
16 | #include <linux/spinlock.h> | ||
17 | #include <linux/errno.h> | ||
18 | |||
19 | #include <asm/system.h> | ||
20 | #include <asm/irq.h> | ||
21 | #include <mach/hardware.h> | ||
22 | #include <mach/dma.h> | ||
23 | |||
24 | |||
25 | #undef DEBUG | ||
26 | #ifdef DEBUG | ||
27 | #define DPRINTK( s, arg... ) printk( "dma<%p>: " s, regs , ##arg ) | ||
28 | #else | ||
29 | #define DPRINTK( x... ) | ||
30 | #endif | ||
31 | |||
32 | |||
33 | typedef struct { | ||
34 | const char *device_id; /* device name */ | ||
35 | u_long device; /* this channel device, 0 if unused*/ | ||
36 | dma_callback_t callback; /* to call when DMA completes */ | ||
37 | void *data; /* ... with private data ptr */ | ||
38 | } sa1100_dma_t; | ||
39 | |||
40 | static sa1100_dma_t dma_chan[SA1100_DMA_CHANNELS]; | ||
41 | |||
42 | static DEFINE_SPINLOCK(dma_list_lock); | ||
43 | |||
44 | |||
45 | static irqreturn_t dma_irq_handler(int irq, void *dev_id) | ||
46 | { | ||
47 | dma_regs_t *dma_regs = dev_id; | ||
48 | sa1100_dma_t *dma = dma_chan + (((u_int)dma_regs >> 5) & 7); | ||
49 | int status = dma_regs->RdDCSR; | ||
50 | |||
51 | if (status & (DCSR_ERROR)) { | ||
52 | printk(KERN_CRIT "DMA on \"%s\" caused an error\n", dma->device_id); | ||
53 | dma_regs->ClrDCSR = DCSR_ERROR; | ||
54 | } | ||
55 | |||
56 | dma_regs->ClrDCSR = status & (DCSR_DONEA | DCSR_DONEB); | ||
57 | if (dma->callback) { | ||
58 | if (status & DCSR_DONEA) | ||
59 | dma->callback(dma->data); | ||
60 | if (status & DCSR_DONEB) | ||
61 | dma->callback(dma->data); | ||
62 | } | ||
63 | return IRQ_HANDLED; | ||
64 | } | ||
65 | |||
66 | |||
67 | /** | ||
68 | * sa1100_request_dma - allocate one of the SA11x0's DMA channels | ||
69 | * @device: The SA11x0 peripheral targeted by this request | ||
70 | * @device_id: An ascii name for the claiming device | ||
71 | * @callback: Function to be called when the DMA completes | ||
72 | * @data: A cookie passed back to the callback function | ||
73 | * @dma_regs: Pointer to the location of the allocated channel's identifier | ||
74 | * | ||
75 | * This function will search for a free DMA channel and returns the | ||
76 | * address of the hardware registers for that channel as the channel | ||
77 | * identifier. This identifier is written to the location pointed by | ||
78 | * @dma_regs. The list of possible values for @device are listed into | ||
79 | * arch/arm/mach-sa1100/include/mach/dma.h as a dma_device_t enum. | ||
80 | * | ||
81 | * Note that reading from a port and writing to the same port are | ||
82 | * actually considered as two different streams requiring separate | ||
83 | * DMA registrations. | ||
84 | * | ||
85 | * The @callback function is called from interrupt context when one | ||
86 | * of the two possible DMA buffers in flight has terminated. That | ||
87 | * function has to be small and efficient while posponing more complex | ||
88 | * processing to a lower priority execution context. | ||
89 | * | ||
90 | * If no channels are available, or if the desired @device is already in | ||
91 | * use by another DMA channel, then an error code is returned. This | ||
92 | * function must be called before any other DMA calls. | ||
93 | **/ | ||
94 | |||
95 | int sa1100_request_dma (dma_device_t device, const char *device_id, | ||
96 | dma_callback_t callback, void *data, | ||
97 | dma_regs_t **dma_regs) | ||
98 | { | ||
99 | sa1100_dma_t *dma = NULL; | ||
100 | dma_regs_t *regs; | ||
101 | int i, err; | ||
102 | |||
103 | *dma_regs = NULL; | ||
104 | |||
105 | err = 0; | ||
106 | spin_lock(&dma_list_lock); | ||
107 | for (i = 0; i < SA1100_DMA_CHANNELS; i++) { | ||
108 | if (dma_chan[i].device == device) { | ||
109 | err = -EBUSY; | ||
110 | break; | ||
111 | } else if (!dma_chan[i].device && !dma) { | ||
112 | dma = &dma_chan[i]; | ||
113 | } | ||
114 | } | ||
115 | if (!err) { | ||
116 | if (dma) | ||
117 | dma->device = device; | ||
118 | else | ||
119 | err = -ENOSR; | ||
120 | } | ||
121 | spin_unlock(&dma_list_lock); | ||
122 | if (err) | ||
123 | return err; | ||
124 | |||
125 | i = dma - dma_chan; | ||
126 | regs = (dma_regs_t *)&DDAR(i); | ||
127 | err = request_irq(IRQ_DMA0 + i, dma_irq_handler, IRQF_DISABLED, | ||
128 | device_id, regs); | ||
129 | if (err) { | ||
130 | printk(KERN_ERR | ||
131 | "%s: unable to request IRQ %d for %s\n", | ||
132 | __func__, IRQ_DMA0 + i, device_id); | ||
133 | dma->device = 0; | ||
134 | return err; | ||
135 | } | ||
136 | |||
137 | *dma_regs = regs; | ||
138 | dma->device_id = device_id; | ||
139 | dma->callback = callback; | ||
140 | dma->data = data; | ||
141 | |||
142 | regs->ClrDCSR = | ||
143 | (DCSR_DONEA | DCSR_DONEB | DCSR_STRTA | DCSR_STRTB | | ||
144 | DCSR_IE | DCSR_ERROR | DCSR_RUN); | ||
145 | regs->DDAR = device; | ||
146 | |||
147 | return 0; | ||
148 | } | ||
149 | |||
150 | |||
151 | /** | ||
152 | * sa1100_free_dma - free a SA11x0 DMA channel | ||
153 | * @regs: identifier for the channel to free | ||
154 | * | ||
155 | * This clears all activities on a given DMA channel and releases it | ||
156 | * for future requests. The @regs identifier is provided by a | ||
157 | * successful call to sa1100_request_dma(). | ||
158 | **/ | ||
159 | |||
160 | void sa1100_free_dma(dma_regs_t *regs) | ||
161 | { | ||
162 | int i; | ||
163 | |||
164 | for (i = 0; i < SA1100_DMA_CHANNELS; i++) | ||
165 | if (regs == (dma_regs_t *)&DDAR(i)) | ||
166 | break; | ||
167 | if (i >= SA1100_DMA_CHANNELS) { | ||
168 | printk(KERN_ERR "%s: bad DMA identifier\n", __func__); | ||
169 | return; | ||
170 | } | ||
171 | |||
172 | if (!dma_chan[i].device) { | ||
173 | printk(KERN_ERR "%s: Trying to free free DMA\n", __func__); | ||
174 | return; | ||
175 | } | ||
176 | |||
177 | regs->ClrDCSR = | ||
178 | (DCSR_DONEA | DCSR_DONEB | DCSR_STRTA | DCSR_STRTB | | ||
179 | DCSR_IE | DCSR_ERROR | DCSR_RUN); | ||
180 | free_irq(IRQ_DMA0 + i, regs); | ||
181 | dma_chan[i].device = 0; | ||
182 | } | ||
183 | |||
184 | |||
185 | /** | ||
186 | * sa1100_start_dma - submit a data buffer for DMA | ||
187 | * @regs: identifier for the channel to use | ||
188 | * @dma_ptr: buffer physical (or bus) start address | ||
189 | * @size: buffer size | ||
190 | * | ||
191 | * This function hands the given data buffer to the hardware for DMA | ||
192 | * access. If another buffer is already in flight then this buffer | ||
193 | * will be queued so the DMA engine will switch to it automatically | ||
194 | * when the previous one is done. The DMA engine is actually toggling | ||
195 | * between two buffers so at most 2 successful calls can be made before | ||
196 | * one of them terminates and the callback function is called. | ||
197 | * | ||
198 | * The @regs identifier is provided by a successful call to | ||
199 | * sa1100_request_dma(). | ||
200 | * | ||
201 | * The @size must not be larger than %MAX_DMA_SIZE. If a given buffer | ||
202 | * is larger than that then it's the caller's responsibility to split | ||
203 | * it into smaller chunks and submit them separately. If this is the | ||
204 | * case then a @size of %CUT_DMA_SIZE is recommended to avoid ending | ||
205 | * up with too small chunks. The callback function can be used to chain | ||
206 | * submissions of buffer chunks. | ||
207 | * | ||
208 | * Error return values: | ||
209 | * %-EOVERFLOW: Given buffer size is too big. | ||
210 | * %-EBUSY: Both DMA buffers are already in use. | ||
211 | * %-EAGAIN: Both buffers were busy but one of them just completed | ||
212 | * but the interrupt handler has to execute first. | ||
213 | * | ||
214 | * This function returs 0 on success. | ||
215 | **/ | ||
216 | |||
217 | int sa1100_start_dma(dma_regs_t *regs, dma_addr_t dma_ptr, u_int size) | ||
218 | { | ||
219 | unsigned long flags; | ||
220 | u_long status; | ||
221 | int ret; | ||
222 | |||
223 | if (dma_ptr & 3) | ||
224 | printk(KERN_WARNING "DMA: unaligned start address (0x%08lx)\n", | ||
225 | (unsigned long)dma_ptr); | ||
226 | |||
227 | if (size > MAX_DMA_SIZE) | ||
228 | return -EOVERFLOW; | ||
229 | |||
230 | local_irq_save(flags); | ||
231 | status = regs->RdDCSR; | ||
232 | |||
233 | /* If both DMA buffers are started, there's nothing else we can do. */ | ||
234 | if ((status & (DCSR_STRTA | DCSR_STRTB)) == (DCSR_STRTA | DCSR_STRTB)) { | ||
235 | DPRINTK("start: st %#x busy\n", status); | ||
236 | ret = -EBUSY; | ||
237 | goto out; | ||
238 | } | ||
239 | |||
240 | if (((status & DCSR_BIU) && (status & DCSR_STRTB)) || | ||
241 | (!(status & DCSR_BIU) && !(status & DCSR_STRTA))) { | ||
242 | if (status & DCSR_DONEA) { | ||
243 | /* give a chance for the interrupt to be processed */ | ||
244 | ret = -EAGAIN; | ||
245 | goto out; | ||
246 | } | ||
247 | regs->DBSA = dma_ptr; | ||
248 | regs->DBTA = size; | ||
249 | regs->SetDCSR = DCSR_STRTA | DCSR_IE | DCSR_RUN; | ||
250 | DPRINTK("start a=%#x s=%d on A\n", dma_ptr, size); | ||
251 | } else { | ||
252 | if (status & DCSR_DONEB) { | ||
253 | /* give a chance for the interrupt to be processed */ | ||
254 | ret = -EAGAIN; | ||
255 | goto out; | ||
256 | } | ||
257 | regs->DBSB = dma_ptr; | ||
258 | regs->DBTB = size; | ||
259 | regs->SetDCSR = DCSR_STRTB | DCSR_IE | DCSR_RUN; | ||
260 | DPRINTK("start a=%#x s=%d on B\n", dma_ptr, size); | ||
261 | } | ||
262 | ret = 0; | ||
263 | |||
264 | out: | ||
265 | local_irq_restore(flags); | ||
266 | return ret; | ||
267 | } | ||
268 | |||
269 | |||
270 | /** | ||
271 | * sa1100_get_dma_pos - return current DMA position | ||
272 | * @regs: identifier for the channel to use | ||
273 | * | ||
274 | * This function returns the current physical (or bus) address for the | ||
275 | * given DMA channel. If the channel is running i.e. not in a stopped | ||
276 | * state then the caller must disable interrupts prior calling this | ||
277 | * function and process the returned value before re-enabling them to | ||
278 | * prevent races with the completion interrupt handler and the callback | ||
279 | * function. The validation of the returned value is the caller's | ||
280 | * responsibility as well -- the hardware seems to return out of range | ||
281 | * values when the DMA engine completes a buffer. | ||
282 | * | ||
283 | * The @regs identifier is provided by a successful call to | ||
284 | * sa1100_request_dma(). | ||
285 | **/ | ||
286 | |||
287 | dma_addr_t sa1100_get_dma_pos(dma_regs_t *regs) | ||
288 | { | ||
289 | int status; | ||
290 | |||
291 | /* | ||
292 | * We must determine whether buffer A or B is active. | ||
293 | * Two possibilities: either we are in the middle of | ||
294 | * a buffer, or the DMA controller just switched to the | ||
295 | * next toggle but the interrupt hasn't been serviced yet. | ||
296 | * The former case is straight forward. In the later case, | ||
297 | * we'll do like if DMA is just at the end of the previous | ||
298 | * toggle since all registers haven't been reset yet. | ||
299 | * This goes around the edge case and since we're always | ||
300 | * a little behind anyways it shouldn't make a big difference. | ||
301 | * If DMA has been stopped prior calling this then the | ||
302 | * position is exact. | ||
303 | */ | ||
304 | status = regs->RdDCSR; | ||
305 | if ((!(status & DCSR_BIU) && (status & DCSR_STRTA)) || | ||
306 | ( (status & DCSR_BIU) && !(status & DCSR_STRTB))) | ||
307 | return regs->DBSA; | ||
308 | else | ||
309 | return regs->DBSB; | ||
310 | } | ||
311 | |||
312 | |||
313 | /** | ||
314 | * sa1100_reset_dma - reset a DMA channel | ||
315 | * @regs: identifier for the channel to use | ||
316 | * | ||
317 | * This function resets and reconfigure the given DMA channel. This is | ||
318 | * particularly useful after a sleep/wakeup event. | ||
319 | * | ||
320 | * The @regs identifier is provided by a successful call to | ||
321 | * sa1100_request_dma(). | ||
322 | **/ | ||
323 | |||
324 | void sa1100_reset_dma(dma_regs_t *regs) | ||
325 | { | ||
326 | int i; | ||
327 | |||
328 | for (i = 0; i < SA1100_DMA_CHANNELS; i++) | ||
329 | if (regs == (dma_regs_t *)&DDAR(i)) | ||
330 | break; | ||
331 | if (i >= SA1100_DMA_CHANNELS) { | ||
332 | printk(KERN_ERR "%s: bad DMA identifier\n", __func__); | ||
333 | return; | ||
334 | } | ||
335 | |||
336 | regs->ClrDCSR = | ||
337 | (DCSR_DONEA | DCSR_DONEB | DCSR_STRTA | DCSR_STRTB | | ||
338 | DCSR_IE | DCSR_ERROR | DCSR_RUN); | ||
339 | regs->DDAR = dma_chan[i].device; | ||
340 | } | ||
341 | |||
342 | |||
343 | EXPORT_SYMBOL(sa1100_request_dma); | ||
344 | EXPORT_SYMBOL(sa1100_free_dma); | ||
345 | EXPORT_SYMBOL(sa1100_start_dma); | ||
346 | EXPORT_SYMBOL(sa1100_get_dma_pos); | ||
347 | EXPORT_SYMBOL(sa1100_reset_dma); | ||
348 | |||
diff --git a/arch/arm/mach-sa1100/gpio.c b/arch/arm/mach-sa1100/gpio.c new file mode 100644 index 00000000000..0d3829a8c2c --- /dev/null +++ b/arch/arm/mach-sa1100/gpio.c | |||
@@ -0,0 +1,65 @@ | |||
1 | /* | ||
2 | * linux/arch/arm/mach-sa1100/gpio.c | ||
3 | * | ||
4 | * Generic SA-1100 GPIO handling | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | */ | ||
10 | |||
11 | #include <linux/init.h> | ||
12 | #include <linux/module.h> | ||
13 | |||
14 | #include <asm/gpio.h> | ||
15 | #include <mach/hardware.h> | ||
16 | #include "generic.h" | ||
17 | |||
18 | static int sa1100_gpio_get(struct gpio_chip *chip, unsigned offset) | ||
19 | { | ||
20 | return GPLR & GPIO_GPIO(offset); | ||
21 | } | ||
22 | |||
23 | static void sa1100_gpio_set(struct gpio_chip *chip, unsigned offset, int value) | ||
24 | { | ||
25 | if (value) | ||
26 | GPSR = GPIO_GPIO(offset); | ||
27 | else | ||
28 | GPCR = GPIO_GPIO(offset); | ||
29 | } | ||
30 | |||
31 | static int sa1100_direction_input(struct gpio_chip *chip, unsigned offset) | ||
32 | { | ||
33 | unsigned long flags; | ||
34 | |||
35 | local_irq_save(flags); | ||
36 | GPDR &= ~GPIO_GPIO(offset); | ||
37 | local_irq_restore(flags); | ||
38 | return 0; | ||
39 | } | ||
40 | |||
41 | static int sa1100_direction_output(struct gpio_chip *chip, unsigned offset, int value) | ||
42 | { | ||
43 | unsigned long flags; | ||
44 | |||
45 | local_irq_save(flags); | ||
46 | sa1100_gpio_set(chip, offset, value); | ||
47 | GPDR |= GPIO_GPIO(offset); | ||
48 | local_irq_restore(flags); | ||
49 | return 0; | ||
50 | } | ||
51 | |||
52 | static struct gpio_chip sa1100_gpio_chip = { | ||
53 | .label = "gpio", | ||
54 | .direction_input = sa1100_direction_input, | ||
55 | .direction_output = sa1100_direction_output, | ||
56 | .set = sa1100_gpio_set, | ||
57 | .get = sa1100_gpio_get, | ||
58 | .base = 0, | ||
59 | .ngpio = GPIO_MAX + 1, | ||
60 | }; | ||
61 | |||
62 | void __init sa1100_init_gpio(void) | ||
63 | { | ||
64 | gpiochip_add(&sa1100_gpio_chip); | ||
65 | } | ||
diff --git a/arch/arm/mach-sa1100/include/mach/SA-1111.h b/arch/arm/mach-sa1100/include/mach/SA-1111.h new file mode 100644 index 00000000000..c38f60915cb --- /dev/null +++ b/arch/arm/mach-sa1100/include/mach/SA-1111.h | |||
@@ -0,0 +1,5 @@ | |||
1 | /* | ||
2 | * Moved to new location | ||
3 | */ | ||
4 | #warning using old SA-1111.h - update to <asm/hardware/sa1111.h> | ||
5 | #include <asm/hardware/sa1111.h> | ||
diff --git a/arch/arm/mach-sa1100/include/mach/dma.h b/arch/arm/mach-sa1100/include/mach/dma.h new file mode 100644 index 00000000000..dda1b351310 --- /dev/null +++ b/arch/arm/mach-sa1100/include/mach/dma.h | |||
@@ -0,0 +1,117 @@ | |||
1 | /* | ||
2 | * arch/arm/mach-sa1100/include/mach/dma.h | ||
3 | * | ||
4 | * Generic SA1100 DMA support | ||
5 | * | ||
6 | * Copyright (C) 2000 Nicolas Pitre | ||
7 | * | ||
8 | */ | ||
9 | |||
10 | #ifndef __ASM_ARCH_DMA_H | ||
11 | #define __ASM_ARCH_DMA_H | ||
12 | |||
13 | #include "hardware.h" | ||
14 | |||
15 | |||
16 | /* | ||
17 | * The SA1100 has six internal DMA channels. | ||
18 | */ | ||
19 | #define SA1100_DMA_CHANNELS 6 | ||
20 | |||
21 | /* | ||
22 | * Maximum physical DMA buffer size | ||
23 | */ | ||
24 | #define MAX_DMA_SIZE 0x1fff | ||
25 | #define CUT_DMA_SIZE 0x1000 | ||
26 | |||
27 | /* | ||
28 | * All possible SA1100 devices a DMA channel can be attached to. | ||
29 | */ | ||
30 | typedef enum { | ||
31 | DMA_Ser0UDCWr = DDAR_Ser0UDCWr, /* Ser. port 0 UDC Write */ | ||
32 | DMA_Ser0UDCRd = DDAR_Ser0UDCRd, /* Ser. port 0 UDC Read */ | ||
33 | DMA_Ser1UARTWr = DDAR_Ser1UARTWr, /* Ser. port 1 UART Write */ | ||
34 | DMA_Ser1UARTRd = DDAR_Ser1UARTRd, /* Ser. port 1 UART Read */ | ||
35 | DMA_Ser1SDLCWr = DDAR_Ser1SDLCWr, /* Ser. port 1 SDLC Write */ | ||
36 | DMA_Ser1SDLCRd = DDAR_Ser1SDLCRd, /* Ser. port 1 SDLC Read */ | ||
37 | DMA_Ser2UARTWr = DDAR_Ser2UARTWr, /* Ser. port 2 UART Write */ | ||
38 | DMA_Ser2UARTRd = DDAR_Ser2UARTRd, /* Ser. port 2 UART Read */ | ||
39 | DMA_Ser2HSSPWr = DDAR_Ser2HSSPWr, /* Ser. port 2 HSSP Write */ | ||
40 | DMA_Ser2HSSPRd = DDAR_Ser2HSSPRd, /* Ser. port 2 HSSP Read */ | ||
41 | DMA_Ser3UARTWr = DDAR_Ser3UARTWr, /* Ser. port 3 UART Write */ | ||
42 | DMA_Ser3UARTRd = DDAR_Ser3UARTRd, /* Ser. port 3 UART Read */ | ||
43 | DMA_Ser4MCP0Wr = DDAR_Ser4MCP0Wr, /* Ser. port 4 MCP 0 Write (audio) */ | ||
44 | DMA_Ser4MCP0Rd = DDAR_Ser4MCP0Rd, /* Ser. port 4 MCP 0 Read (audio) */ | ||
45 | DMA_Ser4MCP1Wr = DDAR_Ser4MCP1Wr, /* Ser. port 4 MCP 1 Write */ | ||
46 | DMA_Ser4MCP1Rd = DDAR_Ser4MCP1Rd, /* Ser. port 4 MCP 1 Read */ | ||
47 | DMA_Ser4SSPWr = DDAR_Ser4SSPWr, /* Ser. port 4 SSP Write (16 bits) */ | ||
48 | DMA_Ser4SSPRd = DDAR_Ser4SSPRd /* Ser. port 4 SSP Read (16 bits) */ | ||
49 | } dma_device_t; | ||
50 | |||
51 | typedef struct { | ||
52 | volatile u_long DDAR; | ||
53 | volatile u_long SetDCSR; | ||
54 | volatile u_long ClrDCSR; | ||
55 | volatile u_long RdDCSR; | ||
56 | volatile dma_addr_t DBSA; | ||
57 | volatile u_long DBTA; | ||
58 | volatile dma_addr_t DBSB; | ||
59 | volatile u_long DBTB; | ||
60 | } dma_regs_t; | ||
61 | |||
62 | typedef void (*dma_callback_t)(void *data); | ||
63 | |||
64 | /* | ||
65 | * DMA function prototypes | ||
66 | */ | ||
67 | |||
68 | extern int sa1100_request_dma( dma_device_t device, const char *device_id, | ||
69 | dma_callback_t callback, void *data, | ||
70 | dma_regs_t **regs ); | ||
71 | extern void sa1100_free_dma( dma_regs_t *regs ); | ||
72 | extern int sa1100_start_dma( dma_regs_t *regs, dma_addr_t dma_ptr, u_int size ); | ||
73 | extern dma_addr_t sa1100_get_dma_pos(dma_regs_t *regs); | ||
74 | extern void sa1100_reset_dma(dma_regs_t *regs); | ||
75 | |||
76 | /** | ||
77 | * sa1100_stop_dma - stop DMA in progress | ||
78 | * @regs: identifier for the channel to use | ||
79 | * | ||
80 | * This stops DMA without clearing buffer pointers. Unlike | ||
81 | * sa1100_clear_dma() this allows subsequent use of sa1100_resume_dma() | ||
82 | * or sa1100_get_dma_pos(). | ||
83 | * | ||
84 | * The @regs identifier is provided by a successful call to | ||
85 | * sa1100_request_dma(). | ||
86 | **/ | ||
87 | |||
88 | #define sa1100_stop_dma(regs) ((regs)->ClrDCSR = DCSR_IE|DCSR_RUN) | ||
89 | |||
90 | /** | ||
91 | * sa1100_resume_dma - resume DMA on a stopped channel | ||
92 | * @regs: identifier for the channel to use | ||
93 | * | ||
94 | * This resumes DMA on a channel previously stopped with | ||
95 | * sa1100_stop_dma(). | ||
96 | * | ||
97 | * The @regs identifier is provided by a successful call to | ||
98 | * sa1100_request_dma(). | ||
99 | **/ | ||
100 | |||
101 | #define sa1100_resume_dma(regs) ((regs)->SetDCSR = DCSR_IE|DCSR_RUN) | ||
102 | |||
103 | /** | ||
104 | * sa1100_clear_dma - clear DMA pointers | ||
105 | * @regs: identifier for the channel to use | ||
106 | * | ||
107 | * This clear any DMA state so the DMA engine is ready to restart | ||
108 | * with new buffers through sa1100_start_dma(). Any buffers in flight | ||
109 | * are discarded. | ||
110 | * | ||
111 | * The @regs identifier is provided by a successful call to | ||
112 | * sa1100_request_dma(). | ||
113 | **/ | ||
114 | |||
115 | #define sa1100_clear_dma(regs) ((regs)->ClrDCSR = DCSR_IE|DCSR_RUN|DCSR_STRTA|DCSR_STRTB) | ||
116 | |||
117 | #endif /* _ASM_ARCH_DMA_H */ | ||
diff --git a/arch/arm/mach-sa1100/include/mach/io.h b/arch/arm/mach-sa1100/include/mach/io.h new file mode 100644 index 00000000000..d8b43f3dcd2 --- /dev/null +++ b/arch/arm/mach-sa1100/include/mach/io.h | |||
@@ -0,0 +1,22 @@ | |||
1 | /* | ||
2 | * arch/arm/mach-sa1100/include/mach/io.h | ||
3 | * | ||
4 | * Copyright (C) 1997-1999 Russell King | ||
5 | * | ||
6 | * Modifications: | ||
7 | * 06-12-1997 RMK Created. | ||
8 | * 07-04-1999 RMK Major cleanup | ||
9 | */ | ||
10 | #ifndef __ASM_ARM_ARCH_IO_H | ||
11 | #define __ASM_ARM_ARCH_IO_H | ||
12 | |||
13 | #define IO_SPACE_LIMIT 0xffffffff | ||
14 | |||
15 | /* | ||
16 | * We don't actually have real ISA nor PCI buses, but there is so many | ||
17 | * drivers out there that might just work if we fake them... | ||
18 | */ | ||
19 | #define __io(a) __typesafe_io(a) | ||
20 | #define __mem_pci(a) (a) | ||
21 | |||
22 | #endif | ||
diff --git a/arch/arm/mach-sa1100/include/mach/lart.h b/arch/arm/mach-sa1100/include/mach/lart.h new file mode 100644 index 00000000000..8a5482d908d --- /dev/null +++ b/arch/arm/mach-sa1100/include/mach/lart.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifndef _INCLUDE_LART_H | ||
2 | #define _INCLUDE_LART_H | ||
3 | |||
4 | #define LART_GPIO_ETH0 GPIO_GPIO0 | ||
5 | #define LART_IRQ_ETH0 IRQ_GPIO0 | ||
6 | |||
7 | #define LART_GPIO_IDE GPIO_GPIO1 | ||
8 | #define LART_IRQ_IDE IRQ_GPIO1 | ||
9 | |||
10 | #define LART_GPIO_UCB1200 GPIO_GPIO18 | ||
11 | #define LART_IRQ_UCB1200 IRQ_GPIO18 | ||
12 | |||
13 | #endif | ||
diff --git a/arch/arm/mach-sa1100/include/mach/mcp.h b/arch/arm/mach-sa1100/include/mach/mcp.h new file mode 100644 index 00000000000..ed1a331508a --- /dev/null +++ b/arch/arm/mach-sa1100/include/mach/mcp.h | |||
@@ -0,0 +1,22 @@ | |||
1 | /* | ||
2 | * arch/arm/mach-sa1100/include/mach/mcp.h | ||
3 | * | ||
4 | * Copyright (C) 2005 Russell King. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | */ | ||
10 | #ifndef __ASM_ARM_ARCH_MCP_H | ||
11 | #define __ASM_ARM_ARCH_MCP_H | ||
12 | |||
13 | #include <linux/types.h> | ||
14 | |||
15 | struct mcp_plat_data { | ||
16 | u32 mccr0; | ||
17 | u32 mccr1; | ||
18 | unsigned int sclk_rate; | ||
19 | int gpio_base; | ||
20 | }; | ||
21 | |||
22 | #endif | ||
diff --git a/arch/arm/mach-sa1100/include/mach/system.h b/arch/arm/mach-sa1100/include/mach/system.h new file mode 100644 index 00000000000..ba9da9f7f18 --- /dev/null +++ b/arch/arm/mach-sa1100/include/mach/system.h | |||
@@ -0,0 +1,22 @@ | |||
1 | /* | ||
2 | * arch/arm/mach-sa1100/include/mach/system.h | ||
3 | * | ||
4 | * Copyright (c) 1999 Nicolas Pitre <nico@fluxnic.net> | ||
5 | */ | ||
6 | #include <mach/hardware.h> | ||
7 | |||
8 | static inline void arch_idle(void) | ||
9 | { | ||
10 | cpu_do_idle(); | ||
11 | } | ||
12 | |||
13 | static inline void arch_reset(char mode, const char *cmd) | ||
14 | { | ||
15 | if (mode == 's') { | ||
16 | /* Jump into ROM at address 0 */ | ||
17 | cpu_reset(0); | ||
18 | } else { | ||
19 | /* Use on-chip reset capability */ | ||
20 | RSRR = RSRR_SWR; | ||
21 | } | ||
22 | } | ||
diff --git a/arch/arm/mach-sa1100/include/mach/vmalloc.h b/arch/arm/mach-sa1100/include/mach/vmalloc.h new file mode 100644 index 00000000000..b3d00239848 --- /dev/null +++ b/arch/arm/mach-sa1100/include/mach/vmalloc.h | |||
@@ -0,0 +1,4 @@ | |||
1 | /* | ||
2 | * arch/arm/mach-sa1100/include/mach/vmalloc.h | ||
3 | */ | ||
4 | #define VMALLOC_END (0xe8000000UL) | ||
diff --git a/arch/arm/mach-sa1100/leds-assabet.c b/arch/arm/mach-sa1100/leds-assabet.c new file mode 100644 index 00000000000..64e9b4b11b5 --- /dev/null +++ b/arch/arm/mach-sa1100/leds-assabet.c | |||
@@ -0,0 +1,114 @@ | |||
1 | /* | ||
2 | * linux/arch/arm/mach-sa1100/leds-assabet.c | ||
3 | * | ||
4 | * Copyright (C) 2000 John Dorsey <john+@cs.cmu.edu> | ||
5 | * | ||
6 | * Original (leds-footbridge.c) by Russell King | ||
7 | * | ||
8 | * Assabet uses the LEDs as follows: | ||
9 | * - Green - toggles state every 50 timer interrupts | ||
10 | * - Red - on if system is not idle | ||
11 | */ | ||
12 | #include <linux/init.h> | ||
13 | |||
14 | #include <mach/hardware.h> | ||
15 | #include <asm/leds.h> | ||
16 | #include <asm/system.h> | ||
17 | #include <mach/assabet.h> | ||
18 | |||
19 | #include "leds.h" | ||
20 | |||
21 | |||
22 | #define LED_STATE_ENABLED 1 | ||
23 | #define LED_STATE_CLAIMED 2 | ||
24 | |||
25 | static unsigned int led_state; | ||
26 | static unsigned int hw_led_state; | ||
27 | |||
28 | #define ASSABET_BCR_LED_MASK (ASSABET_BCR_LED_GREEN | ASSABET_BCR_LED_RED) | ||
29 | |||
30 | void assabet_leds_event(led_event_t evt) | ||
31 | { | ||
32 | unsigned long flags; | ||
33 | |||
34 | local_irq_save(flags); | ||
35 | |||
36 | switch (evt) { | ||
37 | case led_start: | ||
38 | hw_led_state = ASSABET_BCR_LED_RED | ASSABET_BCR_LED_GREEN; | ||
39 | led_state = LED_STATE_ENABLED; | ||
40 | break; | ||
41 | |||
42 | case led_stop: | ||
43 | led_state &= ~LED_STATE_ENABLED; | ||
44 | hw_led_state = ASSABET_BCR_LED_RED | ASSABET_BCR_LED_GREEN; | ||
45 | ASSABET_BCR_frob(ASSABET_BCR_LED_MASK, hw_led_state); | ||
46 | break; | ||
47 | |||
48 | case led_claim: | ||
49 | led_state |= LED_STATE_CLAIMED; | ||
50 | hw_led_state = ASSABET_BCR_LED_RED | ASSABET_BCR_LED_GREEN; | ||
51 | break; | ||
52 | |||
53 | case led_release: | ||
54 | led_state &= ~LED_STATE_CLAIMED; | ||
55 | hw_led_state = ASSABET_BCR_LED_RED | ASSABET_BCR_LED_GREEN; | ||
56 | break; | ||
57 | |||
58 | #ifdef CONFIG_LEDS_TIMER | ||
59 | case led_timer: | ||
60 | if (!(led_state & LED_STATE_CLAIMED)) | ||
61 | hw_led_state ^= ASSABET_BCR_LED_GREEN; | ||
62 | break; | ||
63 | #endif | ||
64 | |||
65 | #ifdef CONFIG_LEDS_CPU | ||
66 | case led_idle_start: | ||
67 | if (!(led_state & LED_STATE_CLAIMED)) | ||
68 | hw_led_state |= ASSABET_BCR_LED_RED; | ||
69 | break; | ||
70 | |||
71 | case led_idle_end: | ||
72 | if (!(led_state & LED_STATE_CLAIMED)) | ||
73 | hw_led_state &= ~ASSABET_BCR_LED_RED; | ||
74 | break; | ||
75 | #endif | ||
76 | |||
77 | case led_halted: | ||
78 | break; | ||
79 | |||
80 | case led_green_on: | ||
81 | if (led_state & LED_STATE_CLAIMED) | ||
82 | hw_led_state &= ~ASSABET_BCR_LED_GREEN; | ||
83 | break; | ||
84 | |||
85 | case led_green_off: | ||
86 | if (led_state & LED_STATE_CLAIMED) | ||
87 | hw_led_state |= ASSABET_BCR_LED_GREEN; | ||
88 | break; | ||
89 | |||
90 | case led_amber_on: | ||
91 | break; | ||
92 | |||
93 | case led_amber_off: | ||
94 | break; | ||
95 | |||
96 | case led_red_on: | ||
97 | if (led_state & LED_STATE_CLAIMED) | ||
98 | hw_led_state &= ~ASSABET_BCR_LED_RED; | ||
99 | break; | ||
100 | |||
101 | case led_red_off: | ||
102 | if (led_state & LED_STATE_CLAIMED) | ||
103 | hw_led_state |= ASSABET_BCR_LED_RED; | ||
104 | break; | ||
105 | |||
106 | default: | ||
107 | break; | ||
108 | } | ||
109 | |||
110 | if (led_state & LED_STATE_ENABLED) | ||
111 | ASSABET_BCR_frob(ASSABET_BCR_LED_MASK, hw_led_state); | ||
112 | |||
113 | local_irq_restore(flags); | ||
114 | } | ||
diff --git a/arch/arm/mach-sa1100/leds-badge4.c b/arch/arm/mach-sa1100/leds-badge4.c new file mode 100644 index 00000000000..cf1e38458b8 --- /dev/null +++ b/arch/arm/mach-sa1100/leds-badge4.c | |||
@@ -0,0 +1,111 @@ | |||
1 | /* | ||
2 | * linux/arch/arm/mach-sa1100/leds-badge4.c | ||
3 | * | ||
4 | * Author: Christopher Hoover <ch@hpl.hp.com> | ||
5 | * Copyright (C) 2002 Hewlett-Packard Company | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | * | ||
11 | */ | ||
12 | |||
13 | #include <linux/init.h> | ||
14 | |||
15 | #include <mach/hardware.h> | ||
16 | #include <asm/leds.h> | ||
17 | #include <asm/system.h> | ||
18 | |||
19 | #include "leds.h" | ||
20 | |||
21 | #define LED_STATE_ENABLED 1 | ||
22 | #define LED_STATE_CLAIMED 2 | ||
23 | |||
24 | static unsigned int led_state; | ||
25 | static unsigned int hw_led_state; | ||
26 | |||
27 | #define LED_RED GPIO_GPIO(7) | ||
28 | #define LED_GREEN GPIO_GPIO(9) | ||
29 | #define LED_MASK (LED_RED|LED_GREEN) | ||
30 | |||
31 | #define LED_IDLE LED_GREEN | ||
32 | #define LED_TIMER LED_RED | ||
33 | |||
34 | void badge4_leds_event(led_event_t evt) | ||
35 | { | ||
36 | unsigned long flags; | ||
37 | |||
38 | local_irq_save(flags); | ||
39 | |||
40 | switch (evt) { | ||
41 | case led_start: | ||
42 | GPDR |= LED_MASK; | ||
43 | hw_led_state = LED_MASK; | ||
44 | led_state = LED_STATE_ENABLED; | ||
45 | break; | ||
46 | |||
47 | case led_stop: | ||
48 | led_state &= ~LED_STATE_ENABLED; | ||
49 | break; | ||
50 | |||
51 | case led_claim: | ||
52 | led_state |= LED_STATE_CLAIMED; | ||
53 | hw_led_state = LED_MASK; | ||
54 | break; | ||
55 | |||
56 | case led_release: | ||
57 | led_state &= ~LED_STATE_CLAIMED; | ||
58 | hw_led_state = LED_MASK; | ||
59 | break; | ||
60 | |||
61 | #ifdef CONFIG_LEDS_TIMER | ||
62 | case led_timer: | ||
63 | if (!(led_state & LED_STATE_CLAIMED)) | ||
64 | hw_led_state ^= LED_TIMER; | ||
65 | break; | ||
66 | #endif | ||
67 | |||
68 | #ifdef CONFIG_LEDS_CPU | ||
69 | case led_idle_start: | ||
70 | /* LED off when system is idle */ | ||
71 | if (!(led_state & LED_STATE_CLAIMED)) | ||
72 | hw_led_state &= ~LED_IDLE; | ||
73 | break; | ||
74 | |||
75 | case led_idle_end: | ||
76 | if (!(led_state & LED_STATE_CLAIMED)) | ||
77 | hw_led_state |= LED_IDLE; | ||
78 | break; | ||
79 | #endif | ||
80 | |||
81 | case led_red_on: | ||
82 | if (!(led_state & LED_STATE_CLAIMED)) | ||
83 | hw_led_state &= ~LED_RED; | ||
84 | break; | ||
85 | |||
86 | case led_red_off: | ||
87 | if (!(led_state & LED_STATE_CLAIMED)) | ||
88 | hw_led_state |= LED_RED; | ||
89 | break; | ||
90 | |||
91 | case led_green_on: | ||
92 | if (!(led_state & LED_STATE_CLAIMED)) | ||
93 | hw_led_state &= ~LED_GREEN; | ||
94 | break; | ||
95 | |||
96 | case led_green_off: | ||
97 | if (!(led_state & LED_STATE_CLAIMED)) | ||
98 | hw_led_state |= LED_GREEN; | ||
99 | break; | ||
100 | |||
101 | default: | ||
102 | break; | ||
103 | } | ||
104 | |||
105 | if (led_state & LED_STATE_ENABLED) { | ||
106 | GPSR = hw_led_state; | ||
107 | GPCR = hw_led_state ^ LED_MASK; | ||
108 | } | ||
109 | |||
110 | local_irq_restore(flags); | ||
111 | } | ||
diff --git a/arch/arm/mach-sa1100/leds-cerf.c b/arch/arm/mach-sa1100/leds-cerf.c new file mode 100644 index 00000000000..259b48e0be8 --- /dev/null +++ b/arch/arm/mach-sa1100/leds-cerf.c | |||
@@ -0,0 +1,110 @@ | |||
1 | /* | ||
2 | * linux/arch/arm/mach-sa1100/leds-cerf.c | ||
3 | * | ||
4 | * Author: ??? | ||
5 | */ | ||
6 | #include <linux/init.h> | ||
7 | |||
8 | #include <mach/hardware.h> | ||
9 | #include <asm/leds.h> | ||
10 | #include <asm/system.h> | ||
11 | |||
12 | #include "leds.h" | ||
13 | |||
14 | |||
15 | #define LED_STATE_ENABLED 1 | ||
16 | #define LED_STATE_CLAIMED 2 | ||
17 | |||
18 | static unsigned int led_state; | ||
19 | static unsigned int hw_led_state; | ||
20 | |||
21 | #define LED_D0 GPIO_GPIO(0) | ||
22 | #define LED_D1 GPIO_GPIO(1) | ||
23 | #define LED_D2 GPIO_GPIO(2) | ||
24 | #define LED_D3 GPIO_GPIO(3) | ||
25 | #define LED_MASK (LED_D0|LED_D1|LED_D2|LED_D3) | ||
26 | |||
27 | void cerf_leds_event(led_event_t evt) | ||
28 | { | ||
29 | unsigned long flags; | ||
30 | |||
31 | local_irq_save(flags); | ||
32 | |||
33 | switch (evt) { | ||
34 | case led_start: | ||
35 | hw_led_state = LED_MASK; | ||
36 | led_state = LED_STATE_ENABLED; | ||
37 | break; | ||
38 | |||
39 | case led_stop: | ||
40 | led_state &= ~LED_STATE_ENABLED; | ||
41 | break; | ||
42 | |||
43 | case led_claim: | ||
44 | led_state |= LED_STATE_CLAIMED; | ||
45 | hw_led_state = LED_MASK; | ||
46 | break; | ||
47 | case led_release: | ||
48 | led_state &= ~LED_STATE_CLAIMED; | ||
49 | hw_led_state = LED_MASK; | ||
50 | break; | ||
51 | |||
52 | #ifdef CONFIG_LEDS_TIMER | ||
53 | case led_timer: | ||
54 | if (!(led_state & LED_STATE_CLAIMED)) | ||
55 | hw_led_state ^= LED_D0; | ||
56 | break; | ||
57 | #endif | ||
58 | |||
59 | #ifdef CONFIG_LEDS_CPU | ||
60 | case led_idle_start: | ||
61 | if (!(led_state & LED_STATE_CLAIMED)) | ||
62 | hw_led_state &= ~LED_D1; | ||
63 | break; | ||
64 | |||
65 | case led_idle_end: | ||
66 | if (!(led_state & LED_STATE_CLAIMED)) | ||
67 | hw_led_state |= LED_D1; | ||
68 | break; | ||
69 | #endif | ||
70 | case led_green_on: | ||
71 | if (!(led_state & LED_STATE_CLAIMED)) | ||
72 | hw_led_state &= ~LED_D2; | ||
73 | break; | ||
74 | |||
75 | case led_green_off: | ||
76 | if (!(led_state & LED_STATE_CLAIMED)) | ||
77 | hw_led_state |= LED_D2; | ||
78 | break; | ||
79 | |||
80 | case led_amber_on: | ||
81 | if (!(led_state & LED_STATE_CLAIMED)) | ||
82 | hw_led_state &= ~LED_D3; | ||
83 | break; | ||
84 | |||
85 | case led_amber_off: | ||
86 | if (!(led_state & LED_STATE_CLAIMED)) | ||
87 | hw_led_state |= LED_D3; | ||
88 | break; | ||
89 | |||
90 | case led_red_on: | ||
91 | if (!(led_state & LED_STATE_CLAIMED)) | ||
92 | hw_led_state &= ~LED_D1; | ||
93 | break; | ||
94 | |||
95 | case led_red_off: | ||
96 | if (!(led_state & LED_STATE_CLAIMED)) | ||
97 | hw_led_state |= LED_D1; | ||
98 | break; | ||
99 | |||
100 | default: | ||
101 | break; | ||
102 | } | ||
103 | |||
104 | if (led_state & LED_STATE_ENABLED) { | ||
105 | GPSR = hw_led_state; | ||
106 | GPCR = hw_led_state ^ LED_MASK; | ||
107 | } | ||
108 | |||
109 | local_irq_restore(flags); | ||
110 | } | ||
diff --git a/arch/arm/mach-sa1100/leds-hackkit.c b/arch/arm/mach-sa1100/leds-hackkit.c new file mode 100644 index 00000000000..2bce137462e --- /dev/null +++ b/arch/arm/mach-sa1100/leds-hackkit.c | |||
@@ -0,0 +1,112 @@ | |||
1 | /* | ||
2 | * linux/arch/arm/mach-sa1100/leds-hackkit.c | ||
3 | * | ||
4 | * based on leds-lart.c | ||
5 | * | ||
6 | * (C) Erik Mouw (J.A.K.Mouw@its.tudelft.nl), April 21, 2000 | ||
7 | * (C) Stefan Eletzhofer <stefan.eletzhofer@eletztrick.de>, 2002 | ||
8 | * | ||
9 | * The HackKit has two leds (GPIO 22/23). The red led (gpio 22) is used | ||
10 | * as cpu led, the green one is used as timer led. | ||
11 | */ | ||
12 | #include <linux/init.h> | ||
13 | |||
14 | #include <mach/hardware.h> | ||
15 | #include <asm/leds.h> | ||
16 | #include <asm/system.h> | ||
17 | |||
18 | #include "leds.h" | ||
19 | |||
20 | |||
21 | #define LED_STATE_ENABLED 1 | ||
22 | #define LED_STATE_CLAIMED 2 | ||
23 | |||
24 | static unsigned int led_state; | ||
25 | static unsigned int hw_led_state; | ||
26 | |||
27 | #define LED_GREEN GPIO_GPIO23 | ||
28 | #define LED_RED GPIO_GPIO22 | ||
29 | #define LED_MASK (LED_RED | LED_GREEN) | ||
30 | |||
31 | void hackkit_leds_event(led_event_t evt) | ||
32 | { | ||
33 | unsigned long flags; | ||
34 | |||
35 | local_irq_save(flags); | ||
36 | |||
37 | switch(evt) { | ||
38 | case led_start: | ||
39 | /* pin 22/23 are outputs */ | ||
40 | GPDR |= LED_MASK; | ||
41 | hw_led_state = LED_MASK; | ||
42 | led_state = LED_STATE_ENABLED; | ||
43 | break; | ||
44 | |||
45 | case led_stop: | ||
46 | led_state &= ~LED_STATE_ENABLED; | ||
47 | break; | ||
48 | |||
49 | case led_claim: | ||
50 | led_state |= LED_STATE_CLAIMED; | ||
51 | hw_led_state = LED_MASK; | ||
52 | break; | ||
53 | |||
54 | case led_release: | ||
55 | led_state &= ~LED_STATE_CLAIMED; | ||
56 | hw_led_state = LED_MASK; | ||
57 | break; | ||
58 | |||
59 | #ifdef CONFIG_LEDS_TIMER | ||
60 | case led_timer: | ||
61 | if (!(led_state & LED_STATE_CLAIMED)) | ||
62 | hw_led_state ^= LED_GREEN; | ||
63 | break; | ||
64 | #endif | ||
65 | |||
66 | #ifdef CONFIG_LEDS_CPU | ||
67 | case led_idle_start: | ||
68 | /* The LART people like the LED to be off when the | ||
69 | system is idle... */ | ||
70 | if (!(led_state & LED_STATE_CLAIMED)) | ||
71 | hw_led_state &= ~LED_RED; | ||
72 | break; | ||
73 | |||
74 | case led_idle_end: | ||
75 | /* ... and on if the system is not idle */ | ||
76 | if (!(led_state & LED_STATE_CLAIMED)) | ||
77 | hw_led_state |= LED_RED; | ||
78 | break; | ||
79 | #endif | ||
80 | |||
81 | case led_red_on: | ||
82 | if (led_state & LED_STATE_CLAIMED) | ||
83 | hw_led_state &= ~LED_RED; | ||
84 | break; | ||
85 | |||
86 | case led_red_off: | ||
87 | if (led_state & LED_STATE_CLAIMED) | ||
88 | hw_led_state |= LED_RED; | ||
89 | break; | ||
90 | |||
91 | case led_green_on: | ||
92 | if (led_state & LED_STATE_CLAIMED) | ||
93 | hw_led_state &= ~LED_GREEN; | ||
94 | break; | ||
95 | |||
96 | case led_green_off: | ||
97 | if (led_state & LED_STATE_CLAIMED) | ||
98 | hw_led_state |= LED_GREEN; | ||
99 | break; | ||
100 | |||
101 | default: | ||
102 | break; | ||
103 | } | ||
104 | |||
105 | /* Now set the GPIO state, or nothing will happen at all */ | ||
106 | if (led_state & LED_STATE_ENABLED) { | ||
107 | GPSR = hw_led_state; | ||
108 | GPCR = hw_led_state ^ LED_MASK; | ||
109 | } | ||
110 | |||
111 | local_irq_restore(flags); | ||
112 | } | ||
diff --git a/arch/arm/mach-sa1100/leds-lart.c b/arch/arm/mach-sa1100/leds-lart.c new file mode 100644 index 00000000000..0505a1fdcdb --- /dev/null +++ b/arch/arm/mach-sa1100/leds-lart.c | |||
@@ -0,0 +1,101 @@ | |||
1 | /* | ||
2 | * linux/arch/arm/mach-sa1100/leds-lart.c | ||
3 | * | ||
4 | * (C) Erik Mouw (J.A.K.Mouw@its.tudelft.nl), April 21, 2000 | ||
5 | * | ||
6 | * LART uses the LED as follows: | ||
7 | * - GPIO23 is the LED, on if system is not idle | ||
8 | * You can use both CONFIG_LEDS_CPU and CONFIG_LEDS_TIMER at the same | ||
9 | * time, but in that case the timer events will still dictate the | ||
10 | * pace of the LED. | ||
11 | */ | ||
12 | #include <linux/init.h> | ||
13 | |||
14 | #include <mach/hardware.h> | ||
15 | #include <asm/leds.h> | ||
16 | #include <asm/system.h> | ||
17 | |||
18 | #include "leds.h" | ||
19 | |||
20 | |||
21 | #define LED_STATE_ENABLED 1 | ||
22 | #define LED_STATE_CLAIMED 2 | ||
23 | |||
24 | static unsigned int led_state; | ||
25 | static unsigned int hw_led_state; | ||
26 | |||
27 | #define LED_23 GPIO_GPIO23 | ||
28 | #define LED_MASK (LED_23) | ||
29 | |||
30 | void lart_leds_event(led_event_t evt) | ||
31 | { | ||
32 | unsigned long flags; | ||
33 | |||
34 | local_irq_save(flags); | ||
35 | |||
36 | switch(evt) { | ||
37 | case led_start: | ||
38 | /* pin 23 is output pin */ | ||
39 | GPDR |= LED_23; | ||
40 | hw_led_state = LED_MASK; | ||
41 | led_state = LED_STATE_ENABLED; | ||
42 | break; | ||
43 | |||
44 | case led_stop: | ||
45 | led_state &= ~LED_STATE_ENABLED; | ||
46 | break; | ||
47 | |||
48 | case led_claim: | ||
49 | led_state |= LED_STATE_CLAIMED; | ||
50 | hw_led_state = LED_MASK; | ||
51 | break; | ||
52 | |||
53 | case led_release: | ||
54 | led_state &= ~LED_STATE_CLAIMED; | ||
55 | hw_led_state = LED_MASK; | ||
56 | break; | ||
57 | |||
58 | #ifdef CONFIG_LEDS_TIMER | ||
59 | case led_timer: | ||
60 | if (!(led_state & LED_STATE_CLAIMED)) | ||
61 | hw_led_state ^= LED_23; | ||
62 | break; | ||
63 | #endif | ||
64 | |||
65 | #ifdef CONFIG_LEDS_CPU | ||
66 | case led_idle_start: | ||
67 | /* The LART people like the LED to be off when the | ||
68 | system is idle... */ | ||
69 | if (!(led_state & LED_STATE_CLAIMED)) | ||
70 | hw_led_state &= ~LED_23; | ||
71 | break; | ||
72 | |||
73 | case led_idle_end: | ||
74 | /* ... and on if the system is not idle */ | ||
75 | if (!(led_state & LED_STATE_CLAIMED)) | ||
76 | hw_led_state |= LED_23; | ||
77 | break; | ||
78 | #endif | ||
79 | |||
80 | case led_red_on: | ||
81 | if (led_state & LED_STATE_CLAIMED) | ||
82 | hw_led_state &= ~LED_23; | ||
83 | break; | ||
84 | |||
85 | case led_red_off: | ||
86 | if (led_state & LED_STATE_CLAIMED) | ||
87 | hw_led_state |= LED_23; | ||
88 | break; | ||
89 | |||
90 | default: | ||
91 | break; | ||
92 | } | ||
93 | |||
94 | /* Now set the GPIO state, or nothing will happen at all */ | ||
95 | if (led_state & LED_STATE_ENABLED) { | ||
96 | GPSR = hw_led_state; | ||
97 | GPCR = hw_led_state ^ LED_MASK; | ||
98 | } | ||
99 | |||
100 | local_irq_restore(flags); | ||
101 | } | ||
diff --git a/arch/arm/mach-sa1100/leds-simpad.c b/arch/arm/mach-sa1100/leds-simpad.c new file mode 100644 index 00000000000..d50f4eeaa12 --- /dev/null +++ b/arch/arm/mach-sa1100/leds-simpad.c | |||
@@ -0,0 +1,100 @@ | |||
1 | /* | ||
2 | * linux/arch/arm/mach-sa1100/leds-simpad.c | ||
3 | * | ||
4 | * Author: Juergen Messerer <juergen.messerer@siemens.ch> | ||
5 | */ | ||
6 | #include <linux/init.h> | ||
7 | |||
8 | #include <mach/hardware.h> | ||
9 | #include <asm/leds.h> | ||
10 | #include <asm/system.h> | ||
11 | #include <mach/simpad.h> | ||
12 | |||
13 | #include "leds.h" | ||
14 | |||
15 | |||
16 | #define LED_STATE_ENABLED 1 | ||
17 | #define LED_STATE_CLAIMED 2 | ||
18 | |||
19 | static unsigned int led_state; | ||
20 | static unsigned int hw_led_state; | ||
21 | |||
22 | #define LED_GREEN (1) | ||
23 | #define LED_MASK (1) | ||
24 | |||
25 | extern void set_cs3_bit(int value); | ||
26 | extern void clear_cs3_bit(int value); | ||
27 | |||
28 | void simpad_leds_event(led_event_t evt) | ||
29 | { | ||
30 | switch (evt) | ||
31 | { | ||
32 | case led_start: | ||
33 | hw_led_state = LED_GREEN; | ||
34 | led_state = LED_STATE_ENABLED; | ||
35 | break; | ||
36 | |||
37 | case led_stop: | ||
38 | led_state &= ~LED_STATE_ENABLED; | ||
39 | break; | ||
40 | |||
41 | case led_claim: | ||
42 | led_state |= LED_STATE_CLAIMED; | ||
43 | hw_led_state = LED_GREEN; | ||
44 | break; | ||
45 | |||
46 | case led_release: | ||
47 | led_state &= ~LED_STATE_CLAIMED; | ||
48 | hw_led_state = LED_GREEN; | ||
49 | break; | ||
50 | |||
51 | #ifdef CONFIG_LEDS_TIMER | ||
52 | case led_timer: | ||
53 | if (!(led_state & LED_STATE_CLAIMED)) | ||
54 | hw_led_state ^= LED_GREEN; | ||
55 | break; | ||
56 | #endif | ||
57 | |||
58 | #ifdef CONFIG_LEDS_CPU | ||
59 | case led_idle_start: | ||
60 | break; | ||
61 | |||
62 | case led_idle_end: | ||
63 | break; | ||
64 | #endif | ||
65 | |||
66 | case led_halted: | ||
67 | break; | ||
68 | |||
69 | case led_green_on: | ||
70 | if (led_state & LED_STATE_CLAIMED) | ||
71 | hw_led_state |= LED_GREEN; | ||
72 | break; | ||
73 | |||
74 | case led_green_off: | ||
75 | if (led_state & LED_STATE_CLAIMED) | ||
76 | hw_led_state &= ~LED_GREEN; | ||
77 | break; | ||
78 | |||
79 | case led_amber_on: | ||
80 | break; | ||
81 | |||
82 | case led_amber_off: | ||
83 | break; | ||
84 | |||
85 | case led_red_on: | ||
86 | break; | ||
87 | |||
88 | case led_red_off: | ||
89 | break; | ||
90 | |||
91 | default: | ||
92 | break; | ||
93 | } | ||
94 | |||
95 | if (led_state & LED_STATE_ENABLED) | ||
96 | set_cs3_bit(LED2_ON); | ||
97 | else | ||
98 | clear_cs3_bit(LED2_ON); | ||
99 | } | ||
100 | |||
diff --git a/arch/arm/mach-sa1100/leds.c b/arch/arm/mach-sa1100/leds.c new file mode 100644 index 00000000000..bbfe197fb4d --- /dev/null +++ b/arch/arm/mach-sa1100/leds.c | |||
@@ -0,0 +1,52 @@ | |||
1 | /* | ||
2 | * linux/arch/arm/mach-sa1100/leds.c | ||
3 | * | ||
4 | * SA1100 LEDs dispatcher | ||
5 | * | ||
6 | * Copyright (C) 2001 Nicolas Pitre | ||
7 | */ | ||
8 | #include <linux/compiler.h> | ||
9 | #include <linux/init.h> | ||
10 | |||
11 | #include <asm/leds.h> | ||
12 | #include <asm/mach-types.h> | ||
13 | |||
14 | #include "leds.h" | ||
15 | |||
16 | static int __init | ||
17 | sa1100_leds_init(void) | ||
18 | { | ||
19 | if (machine_is_assabet()) | ||
20 | leds_event = assabet_leds_event; | ||
21 | if (machine_is_consus()) | ||
22 | leds_event = consus_leds_event; | ||
23 | if (machine_is_badge4()) | ||
24 | leds_event = badge4_leds_event; | ||
25 | if (machine_is_brutus()) | ||
26 | leds_event = brutus_leds_event; | ||
27 | if (machine_is_cerf()) | ||
28 | leds_event = cerf_leds_event; | ||
29 | if (machine_is_flexanet()) | ||
30 | leds_event = flexanet_leds_event; | ||
31 | if (machine_is_graphicsclient()) | ||
32 | leds_event = graphicsclient_leds_event; | ||
33 | if (machine_is_hackkit()) | ||
34 | leds_event = hackkit_leds_event; | ||
35 | if (machine_is_lart()) | ||
36 | leds_event = lart_leds_event; | ||
37 | if (machine_is_pfs168()) | ||
38 | leds_event = pfs168_leds_event; | ||
39 | if (machine_is_graphicsmaster()) | ||
40 | leds_event = graphicsmaster_leds_event; | ||
41 | if (machine_is_adsbitsy()) | ||
42 | leds_event = adsbitsy_leds_event; | ||
43 | if (machine_is_pt_system3()) | ||
44 | leds_event = system3_leds_event; | ||
45 | if (machine_is_simpad()) | ||
46 | leds_event = simpad_leds_event; /* what about machine registry? including led, apm... -zecke */ | ||
47 | |||
48 | leds_event(led_start); | ||
49 | return 0; | ||
50 | } | ||
51 | |||
52 | core_initcall(sa1100_leds_init); | ||
diff --git a/arch/arm/mach-sa1100/leds.h b/arch/arm/mach-sa1100/leds.h new file mode 100644 index 00000000000..68cc9f773d6 --- /dev/null +++ b/arch/arm/mach-sa1100/leds.h | |||
@@ -0,0 +1,14 @@ | |||
1 | extern void assabet_leds_event(led_event_t evt); | ||
2 | extern void badge4_leds_event(led_event_t evt); | ||
3 | extern void consus_leds_event(led_event_t evt); | ||
4 | extern void brutus_leds_event(led_event_t evt); | ||
5 | extern void cerf_leds_event(led_event_t evt); | ||
6 | extern void flexanet_leds_event(led_event_t evt); | ||
7 | extern void graphicsclient_leds_event(led_event_t evt); | ||
8 | extern void hackkit_leds_event(led_event_t evt); | ||
9 | extern void lart_leds_event(led_event_t evt); | ||
10 | extern void pfs168_leds_event(led_event_t evt); | ||
11 | extern void graphicsmaster_leds_event(led_event_t evt); | ||
12 | extern void adsbitsy_leds_event(led_event_t evt); | ||
13 | extern void system3_leds_event(led_event_t evt); | ||
14 | extern void simpad_leds_event(led_event_t evt); | ||