aboutsummaryrefslogtreecommitdiffstats
path: root/arch/m68k/amiga
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/m68k/amiga
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'arch/m68k/amiga')
-rw-r--r--arch/m68k/amiga/Makefile7
-rw-r--r--arch/m68k/amiga/amiga_ksyms.c36
-rw-r--r--arch/m68k/amiga/amiints.c520
-rw-r--r--arch/m68k/amiga/amisound.c113
-rw-r--r--arch/m68k/amiga/chipram.c133
-rw-r--r--arch/m68k/amiga/cia.c180
-rw-r--r--arch/m68k/amiga/config.c1007
-rw-r--r--arch/m68k/amiga/pcmcia.c113
8 files changed, 2109 insertions, 0 deletions
diff --git a/arch/m68k/amiga/Makefile b/arch/m68k/amiga/Makefile
new file mode 100644
index 000000000000..8b415651edee
--- /dev/null
+++ b/arch/m68k/amiga/Makefile
@@ -0,0 +1,7 @@
1#
2# Makefile for Linux arch/m68k/amiga source directory
3#
4
5obj-y := config.o amiints.o cia.o chipram.o amisound.o amiga_ksyms.o
6
7obj-$(CONFIG_AMIGA_PCMCIA) += pcmcia.o
diff --git a/arch/m68k/amiga/amiga_ksyms.c b/arch/m68k/amiga/amiga_ksyms.c
new file mode 100644
index 000000000000..b7bd84c73ea7
--- /dev/null
+++ b/arch/m68k/amiga/amiga_ksyms.c
@@ -0,0 +1,36 @@
1#include <linux/config.h>
2#include <linux/module.h>
3#include <linux/types.h>
4#include <asm/ptrace.h>
5#include <asm/amigahw.h>
6#include <asm/amigaints.h>
7#include <asm/amipcmcia.h>
8
9extern volatile u_short amiga_audio_min_period;
10extern u_short amiga_audio_period;
11
12/*
13 * Add things here when you find the need for it.
14 */
15EXPORT_SYMBOL(amiga_model);
16EXPORT_SYMBOL(amiga_chipset);
17EXPORT_SYMBOL(amiga_hw_present);
18EXPORT_SYMBOL(amiga_eclock);
19EXPORT_SYMBOL(amiga_colorclock);
20EXPORT_SYMBOL(amiga_chip_alloc);
21EXPORT_SYMBOL(amiga_chip_free);
22EXPORT_SYMBOL(amiga_chip_avail);
23EXPORT_SYMBOL(amiga_chip_size);
24EXPORT_SYMBOL(amiga_audio_period);
25EXPORT_SYMBOL(amiga_audio_min_period);
26EXPORT_SYMBOL(amiga_do_irq);
27EXPORT_SYMBOL(amiga_do_irq_list);
28
29#ifdef CONFIG_AMIGA_PCMCIA
30 EXPORT_SYMBOL(pcmcia_reset);
31 EXPORT_SYMBOL(pcmcia_copy_tuple);
32 EXPORT_SYMBOL(pcmcia_program_voltage);
33 EXPORT_SYMBOL(pcmcia_access_speed);
34 EXPORT_SYMBOL(pcmcia_write_enable);
35 EXPORT_SYMBOL(pcmcia_write_disable);
36#endif
diff --git a/arch/m68k/amiga/amiints.c b/arch/m68k/amiga/amiints.c
new file mode 100644
index 000000000000..d9edf2d1a492
--- /dev/null
+++ b/arch/m68k/amiga/amiints.c
@@ -0,0 +1,520 @@
1/*
2 * linux/arch/m68k/amiga/amiints.c -- Amiga Linux interrupt handling code
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file COPYING in the main directory of this archive
6 * for more details.
7 *
8 * 11/07/96: rewritten interrupt handling, irq lists are exists now only for
9 * this sources where it makes sense (VERTB/PORTS/EXTER) and you must
10 * be careful that dev_id for this sources is unique since this the
11 * only possibility to distinguish between different handlers for
12 * free_irq. irq lists also have different irq flags:
13 * - IRQ_FLG_FAST: handler is inserted at top of list (after other
14 * fast handlers)
15 * - IRQ_FLG_SLOW: handler is inserted at bottom of list and before
16 * they're executed irq level is set to the previous
17 * one, but handlers don't need to be reentrant, if
18 * reentrance occurred, slow handlers will be just
19 * called again.
20 * The whole interrupt handling for CIAs is moved to cia.c
21 * /Roman Zippel
22 *
23 * 07/08/99: rewamp of the interrupt handling - we now have two types of
24 * interrupts, normal and fast handlers, fast handlers being
25 * marked with SA_INTERRUPT and runs with all other interrupts
26 * disabled. Normal interrupts disable their own source but
27 * run with all other interrupt sources enabled.
28 * PORTS and EXTER interrupts are always shared even if the
29 * drivers do not explicitly mark this when calling
30 * request_irq which they really should do.
31 * This is similar to the way interrupts are handled on all
32 * other architectures and makes a ton of sense besides
33 * having the advantage of making it easier to share
34 * drivers.
35 * /Jes
36 */
37
38#include <linux/types.h>
39#include <linux/kernel.h>
40#include <linux/sched.h>
41#include <linux/kernel_stat.h>
42#include <linux/init.h>
43#include <linux/errno.h>
44#include <linux/seq_file.h>
45
46#include <asm/system.h>
47#include <asm/irq.h>
48#include <asm/traps.h>
49#include <asm/amigahw.h>
50#include <asm/amigaints.h>
51#include <asm/amipcmcia.h>
52
53extern int cia_request_irq(struct ciabase *base,int irq,
54 irqreturn_t (*handler)(int, void *, struct pt_regs *),
55 unsigned long flags, const char *devname, void *dev_id);
56extern void cia_free_irq(struct ciabase *base, unsigned int irq, void *dev_id);
57extern void cia_init_IRQ(struct ciabase *base);
58extern int cia_get_irq_list(struct ciabase *base, struct seq_file *p);
59
60/* irq node variables for amiga interrupt sources */
61static irq_node_t *ami_irq_list[AMI_STD_IRQS];
62
63static unsigned short amiga_intena_vals[AMI_STD_IRQS] = {
64 [IRQ_AMIGA_VERTB] = IF_VERTB,
65 [IRQ_AMIGA_COPPER] = IF_COPER,
66 [IRQ_AMIGA_AUD0] = IF_AUD0,
67 [IRQ_AMIGA_AUD1] = IF_AUD1,
68 [IRQ_AMIGA_AUD2] = IF_AUD2,
69 [IRQ_AMIGA_AUD3] = IF_AUD3,
70 [IRQ_AMIGA_BLIT] = IF_BLIT,
71 [IRQ_AMIGA_DSKSYN] = IF_DSKSYN,
72 [IRQ_AMIGA_DSKBLK] = IF_DSKBLK,
73 [IRQ_AMIGA_RBF] = IF_RBF,
74 [IRQ_AMIGA_TBE] = IF_TBE,
75 [IRQ_AMIGA_SOFT] = IF_SOFT,
76 [IRQ_AMIGA_PORTS] = IF_PORTS,
77 [IRQ_AMIGA_EXTER] = IF_EXTER
78};
79static const unsigned char ami_servers[AMI_STD_IRQS] = {
80 [IRQ_AMIGA_VERTB] = 1,
81 [IRQ_AMIGA_PORTS] = 1,
82 [IRQ_AMIGA_EXTER] = 1
83};
84
85static short ami_ablecount[AMI_IRQS];
86
87static irqreturn_t ami_badint(int irq, void *dev_id, struct pt_regs *fp)
88{
89 num_spurious += 1;
90 return IRQ_NONE;
91}
92
93/*
94 * void amiga_init_IRQ(void)
95 *
96 * Parameters: None
97 *
98 * Returns: Nothing
99 *
100 * This function should be called during kernel startup to initialize
101 * the amiga IRQ handling routines.
102 */
103
104void __init amiga_init_IRQ(void)
105{
106 int i;
107
108 /* initialize handlers */
109 for (i = 0; i < AMI_STD_IRQS; i++) {
110 if (ami_servers[i]) {
111 ami_irq_list[i] = NULL;
112 } else {
113 ami_irq_list[i] = new_irq_node();
114 ami_irq_list[i]->handler = ami_badint;
115 ami_irq_list[i]->flags = 0;
116 ami_irq_list[i]->dev_id = NULL;
117 ami_irq_list[i]->devname = NULL;
118 ami_irq_list[i]->next = NULL;
119 }
120 }
121 for (i = 0; i < AMI_IRQS; i++)
122 ami_ablecount[i] = 0;
123
124 /* turn off PCMCIA interrupts */
125 if (AMIGAHW_PRESENT(PCMCIA))
126 gayle.inten = GAYLE_IRQ_IDE;
127
128 /* turn off all interrupts and enable the master interrupt bit */
129 custom.intena = 0x7fff;
130 custom.intreq = 0x7fff;
131 custom.intena = IF_SETCLR | IF_INTEN;
132
133 cia_init_IRQ(&ciaa_base);
134 cia_init_IRQ(&ciab_base);
135}
136
137static inline int amiga_insert_irq(irq_node_t **list, irq_node_t *node)
138{
139 unsigned long flags;
140 irq_node_t *cur;
141
142 if (!node->dev_id)
143 printk("%s: Warning: dev_id of %s is zero\n",
144 __FUNCTION__, node->devname);
145
146 local_irq_save(flags);
147
148 cur = *list;
149
150 if (node->flags & SA_INTERRUPT) {
151 if (node->flags & SA_SHIRQ)
152 return -EBUSY;
153 /*
154 * There should never be more than one
155 */
156 while (cur && cur->flags & SA_INTERRUPT) {
157 list = &cur->next;
158 cur = cur->next;
159 }
160 } else {
161 while (cur) {
162 list = &cur->next;
163 cur = cur->next;
164 }
165 }
166
167 node->next = cur;
168 *list = node;
169
170 local_irq_restore(flags);
171 return 0;
172}
173
174static inline void amiga_delete_irq(irq_node_t **list, void *dev_id)
175{
176 unsigned long flags;
177 irq_node_t *node;
178
179 local_irq_save(flags);
180
181 for (node = *list; node; list = &node->next, node = *list) {
182 if (node->dev_id == dev_id) {
183 *list = node->next;
184 /* Mark it as free. */
185 node->handler = NULL;
186 local_irq_restore(flags);
187 return;
188 }
189 }
190 local_irq_restore(flags);
191 printk ("%s: tried to remove invalid irq\n", __FUNCTION__);
192}
193
194/*
195 * amiga_request_irq : add an interrupt service routine for a particular
196 * machine specific interrupt source.
197 * If the addition was successful, it returns 0.
198 */
199
200int amiga_request_irq(unsigned int irq,
201 irqreturn_t (*handler)(int, void *, struct pt_regs *),
202 unsigned long flags, const char *devname, void *dev_id)
203{
204 irq_node_t *node;
205 int error = 0;
206
207 if (irq >= AMI_IRQS) {
208 printk ("%s: Unknown IRQ %d from %s\n", __FUNCTION__,
209 irq, devname);
210 return -ENXIO;
211 }
212
213 if (irq >= IRQ_AMIGA_AUTO)
214 return cpu_request_irq(irq - IRQ_AMIGA_AUTO, handler,
215 flags, devname, dev_id);
216
217 if (irq >= IRQ_AMIGA_CIAB)
218 return cia_request_irq(&ciab_base, irq - IRQ_AMIGA_CIAB,
219 handler, flags, devname, dev_id);
220
221 if (irq >= IRQ_AMIGA_CIAA)
222 return cia_request_irq(&ciaa_base, irq - IRQ_AMIGA_CIAA,
223 handler, flags, devname, dev_id);
224
225 /*
226 * IRQ_AMIGA_PORTS & IRQ_AMIGA_EXTER defaults to shared,
227 * we could add a check here for the SA_SHIRQ flag but all drivers
228 * should be aware of sharing anyway.
229 */
230 if (ami_servers[irq]) {
231 if (!(node = new_irq_node()))
232 return -ENOMEM;
233 node->handler = handler;
234 node->flags = flags;
235 node->dev_id = dev_id;
236 node->devname = devname;
237 node->next = NULL;
238 error = amiga_insert_irq(&ami_irq_list[irq], node);
239 } else {
240 ami_irq_list[irq]->handler = handler;
241 ami_irq_list[irq]->flags = flags;
242 ami_irq_list[irq]->dev_id = dev_id;
243 ami_irq_list[irq]->devname = devname;
244 }
245
246 /* enable the interrupt */
247 if (irq < IRQ_AMIGA_PORTS && !ami_ablecount[irq])
248 custom.intena = IF_SETCLR | amiga_intena_vals[irq];
249
250 return error;
251}
252
253void amiga_free_irq(unsigned int irq, void *dev_id)
254{
255 if (irq >= AMI_IRQS) {
256 printk ("%s: Unknown IRQ %d\n", __FUNCTION__, irq);
257 return;
258 }
259
260 if (irq >= IRQ_AMIGA_AUTO)
261 cpu_free_irq(irq - IRQ_AMIGA_AUTO, dev_id);
262
263 if (irq >= IRQ_AMIGA_CIAB) {
264 cia_free_irq(&ciab_base, irq - IRQ_AMIGA_CIAB, dev_id);
265 return;
266 }
267
268 if (irq >= IRQ_AMIGA_CIAA) {
269 cia_free_irq(&ciaa_base, irq - IRQ_AMIGA_CIAA, dev_id);
270 return;
271 }
272
273 if (ami_servers[irq]) {
274 amiga_delete_irq(&ami_irq_list[irq], dev_id);
275 /* if server list empty, disable the interrupt */
276 if (!ami_irq_list[irq] && irq < IRQ_AMIGA_PORTS)
277 custom.intena = amiga_intena_vals[irq];
278 } else {
279 if (ami_irq_list[irq]->dev_id != dev_id)
280 printk("%s: removing probably wrong IRQ %d from %s\n",
281 __FUNCTION__, irq, ami_irq_list[irq]->devname);
282 ami_irq_list[irq]->handler = ami_badint;
283 ami_irq_list[irq]->flags = 0;
284 ami_irq_list[irq]->dev_id = NULL;
285 ami_irq_list[irq]->devname = NULL;
286 custom.intena = amiga_intena_vals[irq];
287 }
288}
289
290/*
291 * Enable/disable a particular machine specific interrupt source.
292 * Note that this may affect other interrupts in case of a shared interrupt.
293 * This function should only be called for a _very_ short time to change some
294 * internal data, that may not be changed by the interrupt at the same time.
295 * ami_(enable|disable)_irq calls may also be nested.
296 */
297
298void amiga_enable_irq(unsigned int irq)
299{
300 if (irq >= AMI_IRQS) {
301 printk("%s: Unknown IRQ %d\n", __FUNCTION__, irq);
302 return;
303 }
304
305 if (--ami_ablecount[irq])
306 return;
307
308 /* No action for auto-vector interrupts */
309 if (irq >= IRQ_AMIGA_AUTO){
310 printk("%s: Trying to enable auto-vector IRQ %i\n",
311 __FUNCTION__, irq - IRQ_AMIGA_AUTO);
312 return;
313 }
314
315 if (irq >= IRQ_AMIGA_CIAB) {
316 cia_set_irq(&ciab_base, (1 << (irq - IRQ_AMIGA_CIAB)));
317 cia_able_irq(&ciab_base, CIA_ICR_SETCLR |
318 (1 << (irq - IRQ_AMIGA_CIAB)));
319 return;
320 }
321
322 if (irq >= IRQ_AMIGA_CIAA) {
323 cia_set_irq(&ciaa_base, (1 << (irq - IRQ_AMIGA_CIAA)));
324 cia_able_irq(&ciaa_base, CIA_ICR_SETCLR |
325 (1 << (irq - IRQ_AMIGA_CIAA)));
326 return;
327 }
328
329 /* enable the interrupt */
330 custom.intena = IF_SETCLR | amiga_intena_vals[irq];
331}
332
333void amiga_disable_irq(unsigned int irq)
334{
335 if (irq >= AMI_IRQS) {
336 printk("%s: Unknown IRQ %d\n", __FUNCTION__, irq);
337 return;
338 }
339
340 if (ami_ablecount[irq]++)
341 return;
342
343 /* No action for auto-vector interrupts */
344 if (irq >= IRQ_AMIGA_AUTO) {
345 printk("%s: Trying to disable auto-vector IRQ %i\n",
346 __FUNCTION__, irq - IRQ_AMIGA_AUTO);
347 return;
348 }
349
350 if (irq >= IRQ_AMIGA_CIAB) {
351 cia_able_irq(&ciab_base, 1 << (irq - IRQ_AMIGA_CIAB));
352 return;
353 }
354
355 if (irq >= IRQ_AMIGA_CIAA) {
356 cia_able_irq(&ciaa_base, 1 << (irq - IRQ_AMIGA_CIAA));
357 return;
358 }
359
360 /* disable the interrupt */
361 custom.intena = amiga_intena_vals[irq];
362}
363
364inline void amiga_do_irq(int irq, struct pt_regs *fp)
365{
366 kstat_cpu(0).irqs[SYS_IRQS + irq]++;
367 ami_irq_list[irq]->handler(irq, ami_irq_list[irq]->dev_id, fp);
368}
369
370void amiga_do_irq_list(int irq, struct pt_regs *fp)
371{
372 irq_node_t *node;
373
374 kstat_cpu(0).irqs[SYS_IRQS + irq]++;
375
376 custom.intreq = amiga_intena_vals[irq];
377
378 for (node = ami_irq_list[irq]; node; node = node->next)
379 node->handler(irq, node->dev_id, fp);
380}
381
382/*
383 * The builtin Amiga hardware interrupt handlers.
384 */
385
386static irqreturn_t ami_int1(int irq, void *dev_id, struct pt_regs *fp)
387{
388 unsigned short ints = custom.intreqr & custom.intenar;
389
390 /* if serial transmit buffer empty, interrupt */
391 if (ints & IF_TBE) {
392 custom.intreq = IF_TBE;
393 amiga_do_irq(IRQ_AMIGA_TBE, fp);
394 }
395
396 /* if floppy disk transfer complete, interrupt */
397 if (ints & IF_DSKBLK) {
398 custom.intreq = IF_DSKBLK;
399 amiga_do_irq(IRQ_AMIGA_DSKBLK, fp);
400 }
401
402 /* if software interrupt set, interrupt */
403 if (ints & IF_SOFT) {
404 custom.intreq = IF_SOFT;
405 amiga_do_irq(IRQ_AMIGA_SOFT, fp);
406 }
407 return IRQ_HANDLED;
408}
409
410static irqreturn_t ami_int3(int irq, void *dev_id, struct pt_regs *fp)
411{
412 unsigned short ints = custom.intreqr & custom.intenar;
413
414 /* if a blitter interrupt */
415 if (ints & IF_BLIT) {
416 custom.intreq = IF_BLIT;
417 amiga_do_irq(IRQ_AMIGA_BLIT, fp);
418 }
419
420 /* if a copper interrupt */
421 if (ints & IF_COPER) {
422 custom.intreq = IF_COPER;
423 amiga_do_irq(IRQ_AMIGA_COPPER, fp);
424 }
425
426 /* if a vertical blank interrupt */
427 if (ints & IF_VERTB)
428 amiga_do_irq_list(IRQ_AMIGA_VERTB, fp);
429 return IRQ_HANDLED;
430}
431
432static irqreturn_t ami_int4(int irq, void *dev_id, struct pt_regs *fp)
433{
434 unsigned short ints = custom.intreqr & custom.intenar;
435
436 /* if audio 0 interrupt */
437 if (ints & IF_AUD0) {
438 custom.intreq = IF_AUD0;
439 amiga_do_irq(IRQ_AMIGA_AUD0, fp);
440 }
441
442 /* if audio 1 interrupt */
443 if (ints & IF_AUD1) {
444 custom.intreq = IF_AUD1;
445 amiga_do_irq(IRQ_AMIGA_AUD1, fp);
446 }
447
448 /* if audio 2 interrupt */
449 if (ints & IF_AUD2) {
450 custom.intreq = IF_AUD2;
451 amiga_do_irq(IRQ_AMIGA_AUD2, fp);
452 }
453
454 /* if audio 3 interrupt */
455 if (ints & IF_AUD3) {
456 custom.intreq = IF_AUD3;
457 amiga_do_irq(IRQ_AMIGA_AUD3, fp);
458 }
459 return IRQ_HANDLED;
460}
461
462static irqreturn_t ami_int5(int irq, void *dev_id, struct pt_regs *fp)
463{
464 unsigned short ints = custom.intreqr & custom.intenar;
465
466 /* if serial receive buffer full interrupt */
467 if (ints & IF_RBF) {
468 /* acknowledge of IF_RBF must be done by the serial interrupt */
469 amiga_do_irq(IRQ_AMIGA_RBF, fp);
470 }
471
472 /* if a disk sync interrupt */
473 if (ints & IF_DSKSYN) {
474 custom.intreq = IF_DSKSYN;
475 amiga_do_irq(IRQ_AMIGA_DSKSYN, fp);
476 }
477 return IRQ_HANDLED;
478}
479
480static irqreturn_t ami_int7(int irq, void *dev_id, struct pt_regs *fp)
481{
482 panic ("level 7 interrupt received\n");
483}
484
485irqreturn_t (*amiga_default_handler[SYS_IRQS])(int, void *, struct pt_regs *) = {
486 [0] = ami_badint,
487 [1] = ami_int1,
488 [2] = ami_badint,
489 [3] = ami_int3,
490 [4] = ami_int4,
491 [5] = ami_int5,
492 [6] = ami_badint,
493 [7] = ami_int7
494};
495
496int show_amiga_interrupts(struct seq_file *p, void *v)
497{
498 int i;
499 irq_node_t *node;
500
501 for (i = 0; i < AMI_STD_IRQS; i++) {
502 if (!(node = ami_irq_list[i]))
503 continue;
504 seq_printf(p, "ami %2d: %10u ", i,
505 kstat_cpu(0).irqs[SYS_IRQS + i]);
506 do {
507 if (node->flags & SA_INTERRUPT)
508 seq_puts(p, "F ");
509 else
510 seq_puts(p, " ");
511 seq_printf(p, "%s\n", node->devname);
512 if ((node = node->next))
513 seq_puts(p, " ");
514 } while (node);
515 }
516
517 cia_get_irq_list(&ciaa_base, p);
518 cia_get_irq_list(&ciab_base, p);
519 return 0;
520}
diff --git a/arch/m68k/amiga/amisound.c b/arch/m68k/amiga/amisound.c
new file mode 100644
index 000000000000..cb5d93630467
--- /dev/null
+++ b/arch/m68k/amiga/amisound.c
@@ -0,0 +1,113 @@
1/*
2 * linux/arch/m68k/amiga/amisound.c
3 *
4 * amiga sound driver for Linux/m68k
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file COPYING in the main directory of this archive
8 * for more details.
9 */
10
11#include <linux/config.h>
12#include <linux/jiffies.h>
13#include <linux/timer.h>
14#include <linux/init.h>
15#include <linux/string.h>
16
17#include <asm/system.h>
18#include <asm/amigahw.h>
19
20static unsigned short *snd_data;
21static const signed char sine_data[] = {
22 0, 39, 75, 103, 121, 127, 121, 103, 75, 39,
23 0, -39, -75, -103, -121, -127, -121, -103, -75, -39
24};
25#define DATA_SIZE (sizeof(sine_data)/sizeof(sine_data[0]))
26
27 /*
28 * The minimum period for audio may be modified by the frame buffer
29 * device since it depends on htotal (for OCS/ECS/AGA)
30 */
31
32volatile unsigned short amiga_audio_min_period = 124; /* Default for pre-OCS */
33
34#define MAX_PERIOD (65535)
35
36
37 /*
38 * Current period (set by dmasound.c)
39 */
40
41unsigned short amiga_audio_period = MAX_PERIOD;
42
43static unsigned long clock_constant;
44
45void __init amiga_init_sound(void)
46{
47 static struct resource beep_res = { .name = "Beep" };
48
49 snd_data = amiga_chip_alloc_res(sizeof(sine_data), &beep_res);
50 if (!snd_data) {
51 printk (KERN_CRIT "amiga init_sound: failed to allocate chipmem\n");
52 return;
53 }
54 memcpy (snd_data, sine_data, sizeof(sine_data));
55
56 /* setup divisor */
57 clock_constant = (amiga_colorclock+DATA_SIZE/2)/DATA_SIZE;
58
59 /* without amifb, turn video off and enable high quality sound */
60#ifndef CONFIG_FB_AMIGA
61 amifb_video_off();
62#endif
63}
64
65static void nosound( unsigned long ignored );
66static struct timer_list sound_timer = TIMER_INITIALIZER(nosound, 0, 0);
67
68void amiga_mksound( unsigned int hz, unsigned int ticks )
69{
70 unsigned long flags;
71
72 if (!snd_data)
73 return;
74
75 local_irq_save(flags);
76 del_timer( &sound_timer );
77
78 if (hz > 20 && hz < 32767) {
79 unsigned long period = (clock_constant / hz);
80
81 if (period < amiga_audio_min_period)
82 period = amiga_audio_min_period;
83 if (period > MAX_PERIOD)
84 period = MAX_PERIOD;
85
86 /* setup pointer to data, period, length and volume */
87 custom.aud[2].audlc = snd_data;
88 custom.aud[2].audlen = sizeof(sine_data)/2;
89 custom.aud[2].audper = (unsigned short)period;
90 custom.aud[2].audvol = 32; /* 50% of maxvol */
91
92 if (ticks) {
93 sound_timer.expires = jiffies + ticks;
94 add_timer( &sound_timer );
95 }
96
97 /* turn on DMA for audio channel 2 */
98 custom.dmacon = DMAF_SETCLR | DMAF_AUD2;
99
100 } else
101 nosound( 0 );
102
103 local_irq_restore(flags);
104}
105
106
107static void nosound( unsigned long ignored )
108{
109 /* turn off DMA for audio channel 2 */
110 custom.dmacon = DMAF_AUD2;
111 /* restore period to previous value after beeping */
112 custom.aud[2].audper = amiga_audio_period;
113}
diff --git a/arch/m68k/amiga/chipram.c b/arch/m68k/amiga/chipram.c
new file mode 100644
index 000000000000..558d5fd2d2ba
--- /dev/null
+++ b/arch/m68k/amiga/chipram.c
@@ -0,0 +1,133 @@
1/*
2** linux/amiga/chipram.c
3**
4** Modified 03-May-94 by Geert Uytterhoeven <geert@linux-m68k.org>
5** - 64-bit aligned allocations for full AGA compatibility
6**
7** Rewritten 15/9/2000 by Geert to use resource management
8*/
9
10#include <linux/config.h>
11#include <linux/types.h>
12#include <linux/kernel.h>
13#include <linux/init.h>
14#include <linux/ioport.h>
15#include <linux/slab.h>
16#include <linux/string.h>
17#include <asm/page.h>
18#include <asm/amigahw.h>
19
20unsigned long amiga_chip_size;
21
22static struct resource chipram_res = {
23 .name = "Chip RAM", .start = CHIP_PHYSADDR
24};
25static unsigned long chipavail;
26
27
28void __init amiga_chip_init(void)
29{
30 if (!AMIGAHW_PRESENT(CHIP_RAM))
31 return;
32
33#ifndef CONFIG_APUS_FAST_EXCEPT
34 /*
35 * Remove the first 4 pages where PPC exception handlers will be located
36 */
37 amiga_chip_size -= 0x4000;
38#endif
39 chipram_res.end = amiga_chip_size-1;
40 request_resource(&iomem_resource, &chipram_res);
41
42 chipavail = amiga_chip_size;
43}
44
45
46void *amiga_chip_alloc(unsigned long size, const char *name)
47{
48 struct resource *res;
49
50 /* round up */
51 size = PAGE_ALIGN(size);
52
53#ifdef DEBUG
54 printk("amiga_chip_alloc: allocate %ld bytes\n", size);
55#endif
56 res = kmalloc(sizeof(struct resource), GFP_KERNEL);
57 if (!res)
58 return NULL;
59 memset(res, 0, sizeof(struct resource));
60 res->name = name;
61
62 if (allocate_resource(&chipram_res, res, size, 0, UINT_MAX, PAGE_SIZE, NULL, NULL) < 0) {
63 kfree(res);
64 return NULL;
65 }
66 chipavail -= size;
67#ifdef DEBUG
68 printk("amiga_chip_alloc: returning %lx\n", res->start);
69#endif
70 return (void *)ZTWO_VADDR(res->start);
71}
72
73
74 /*
75 * Warning:
76 * amiga_chip_alloc_res is meant only for drivers that need to allocate
77 * Chip RAM before kmalloc() is functional. As a consequence, those
78 * drivers must not free that Chip RAM afterwards.
79 */
80
81void * __init amiga_chip_alloc_res(unsigned long size, struct resource *res)
82{
83 unsigned long start;
84
85 /* round up */
86 size = PAGE_ALIGN(size);
87 /* dmesg into chipmem prefers memory at the safe end */
88 start = CHIP_PHYSADDR + chipavail - size;
89
90#ifdef DEBUG
91 printk("amiga_chip_alloc_res: allocate %ld bytes\n", size);
92#endif
93 if (allocate_resource(&chipram_res, res, size, start, UINT_MAX, PAGE_SIZE, NULL, NULL) < 0) {
94 printk("amiga_chip_alloc_res: first alloc failed!\n");
95 if (allocate_resource(&chipram_res, res, size, 0, UINT_MAX, PAGE_SIZE, NULL, NULL) < 0)
96 return NULL;
97 }
98 chipavail -= size;
99#ifdef DEBUG
100 printk("amiga_chip_alloc_res: returning %lx\n", res->start);
101#endif
102 return (void *)ZTWO_VADDR(res->start);
103}
104
105void amiga_chip_free(void *ptr)
106{
107 unsigned long start = ZTWO_PADDR(ptr);
108 struct resource **p, *res;
109 unsigned long size;
110
111 for (p = &chipram_res.child; (res = *p); p = &res->sibling) {
112 if (res->start != start)
113 continue;
114 *p = res->sibling;
115 size = res->end-start;
116#ifdef DEBUG
117 printk("amiga_chip_free: free %ld bytes at %p\n", size, ptr);
118#endif
119 chipavail += size;
120 kfree(res);
121 return;
122 }
123 printk("amiga_chip_free: trying to free nonexistent region at %p\n", ptr);
124}
125
126
127unsigned long amiga_chip_avail(void)
128{
129#ifdef DEBUG
130 printk("amiga_chip_avail : %ld bytes\n", chipavail);
131#endif
132 return chipavail;
133}
diff --git a/arch/m68k/amiga/cia.c b/arch/m68k/amiga/cia.c
new file mode 100644
index 000000000000..7d55682615e3
--- /dev/null
+++ b/arch/m68k/amiga/cia.c
@@ -0,0 +1,180 @@
1/*
2 * linux/arch/m68k/amiga/cia.c - CIA support
3 *
4 * Copyright (C) 1996 Roman Zippel
5 *
6 * The concept of some functions bases on the original Amiga OS function
7 *
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file COPYING in the main directory of this archive
10 * for more details.
11 */
12
13#include <linux/types.h>
14#include <linux/kernel.h>
15#include <linux/sched.h>
16#include <linux/errno.h>
17#include <linux/kernel_stat.h>
18#include <linux/init.h>
19#include <linux/seq_file.h>
20#include <linux/interrupt.h>
21
22#include <asm/irq.h>
23#include <asm/amigahw.h>
24#include <asm/amigaints.h>
25
26struct ciabase {
27 volatile struct CIA *cia;
28 unsigned char icr_mask, icr_data;
29 unsigned short int_mask;
30 int handler_irq, cia_irq, server_irq;
31 char *name;
32 irq_handler_t irq_list[CIA_IRQS];
33} ciaa_base = {
34 .cia = &ciaa,
35 .int_mask = IF_PORTS,
36 .handler_irq = IRQ_AMIGA_AUTO_2,
37 .cia_irq = IRQ_AMIGA_CIAA,
38 .server_irq = IRQ_AMIGA_PORTS,
39 .name = "CIAA handler"
40}, ciab_base = {
41 .cia = &ciab,
42 .int_mask = IF_EXTER,
43 .handler_irq = IRQ_AMIGA_AUTO_6,
44 .cia_irq = IRQ_AMIGA_CIAB,
45 .server_irq = IRQ_AMIGA_EXTER,
46 .name = "CIAB handler"
47};
48
49/*
50 * Cause or clear CIA interrupts, return old interrupt status.
51 */
52
53unsigned char cia_set_irq(struct ciabase *base, unsigned char mask)
54{
55 unsigned char old;
56
57 old = (base->icr_data |= base->cia->icr);
58 if (mask & CIA_ICR_SETCLR)
59 base->icr_data |= mask;
60 else
61 base->icr_data &= ~mask;
62 if (base->icr_data & base->icr_mask)
63 custom.intreq = IF_SETCLR | base->int_mask;
64 return old & base->icr_mask;
65}
66
67/*
68 * Enable or disable CIA interrupts, return old interrupt mask,
69 * interrupts will only be enabled if a handler exists
70 */
71
72unsigned char cia_able_irq(struct ciabase *base, unsigned char mask)
73{
74 unsigned char old, tmp;
75 int i;
76
77 old = base->icr_mask;
78 base->icr_data |= base->cia->icr;
79 base->cia->icr = mask;
80 if (mask & CIA_ICR_SETCLR)
81 base->icr_mask |= mask;
82 else
83 base->icr_mask &= ~mask;
84 base->icr_mask &= CIA_ICR_ALL;
85 for (i = 0, tmp = 1; i < CIA_IRQS; i++, tmp <<= 1) {
86 if ((tmp & base->icr_mask) && !base->irq_list[i].handler) {
87 base->icr_mask &= ~tmp;
88 base->cia->icr = tmp;
89 }
90 }
91 if (base->icr_data & base->icr_mask)
92 custom.intreq = IF_SETCLR | base->int_mask;
93 return old;
94}
95
96int cia_request_irq(struct ciabase *base, unsigned int irq,
97 irqreturn_t (*handler)(int, void *, struct pt_regs *),
98 unsigned long flags, const char *devname, void *dev_id)
99{
100 unsigned char mask;
101
102 base->irq_list[irq].handler = handler;
103 base->irq_list[irq].flags = flags;
104 base->irq_list[irq].dev_id = dev_id;
105 base->irq_list[irq].devname = devname;
106
107 /* enable the interrupt */
108 mask = 1 << irq;
109 cia_set_irq(base, mask);
110 cia_able_irq(base, CIA_ICR_SETCLR | mask);
111 return 0;
112}
113
114void cia_free_irq(struct ciabase *base, unsigned int irq, void *dev_id)
115{
116 if (base->irq_list[irq].dev_id != dev_id)
117 printk("%s: removing probably wrong IRQ %i from %s\n",
118 __FUNCTION__, base->cia_irq + irq,
119 base->irq_list[irq].devname);
120
121 base->irq_list[irq].handler = NULL;
122 base->irq_list[irq].flags = 0;
123
124 cia_able_irq(base, 1 << irq);
125}
126
127static irqreturn_t cia_handler(int irq, void *dev_id, struct pt_regs *fp)
128{
129 struct ciabase *base = (struct ciabase *)dev_id;
130 int mach_irq, i;
131 unsigned char ints;
132
133 mach_irq = base->cia_irq;
134 irq = SYS_IRQS + mach_irq;
135 ints = cia_set_irq(base, CIA_ICR_ALL);
136 custom.intreq = base->int_mask;
137 for (i = 0; i < CIA_IRQS; i++, irq++, mach_irq++) {
138 if (ints & 1) {
139 kstat_cpu(0).irqs[irq]++;
140 base->irq_list[i].handler(mach_irq, base->irq_list[i].dev_id, fp);
141 }
142 ints >>= 1;
143 }
144 amiga_do_irq_list(base->server_irq, fp);
145 return IRQ_HANDLED;
146}
147
148void __init cia_init_IRQ(struct ciabase *base)
149{
150 int i;
151
152 /* init isr handlers */
153 for (i = 0; i < CIA_IRQS; i++) {
154 base->irq_list[i].handler = NULL;
155 base->irq_list[i].flags = 0;
156 }
157
158 /* clear any pending interrupt and turn off all interrupts */
159 cia_set_irq(base, CIA_ICR_ALL);
160 cia_able_irq(base, CIA_ICR_ALL);
161
162 /* install CIA handler */
163 request_irq(base->handler_irq, cia_handler, 0, base->name, base);
164
165 custom.intena = IF_SETCLR | base->int_mask;
166}
167
168int cia_get_irq_list(struct ciabase *base, struct seq_file *p)
169{
170 int i, j;
171
172 j = base->cia_irq;
173 for (i = 0; i < CIA_IRQS; i++) {
174 seq_printf(p, "cia %2d: %10d ", j + i,
175 kstat_cpu(0).irqs[SYS_IRQS + j + i]);
176 seq_puts(p, " ");
177 seq_printf(p, "%s\n", base->irq_list[i].devname);
178 }
179 return 0;
180}
diff --git a/arch/m68k/amiga/config.c b/arch/m68k/amiga/config.c
new file mode 100644
index 000000000000..4775e18a78f0
--- /dev/null
+++ b/arch/m68k/amiga/config.c
@@ -0,0 +1,1007 @@
1/*
2 * linux/arch/m68k/amiga/config.c
3 *
4 * Copyright (C) 1993 Hamish Macdonald
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file COPYING in the main directory of this archive
8 * for more details.
9 */
10
11/*
12 * Miscellaneous Amiga stuff
13 */
14
15#include <linux/config.h>
16#include <linux/types.h>
17#include <linux/kernel.h>
18#include <linux/mm.h>
19#include <linux/tty.h>
20#include <linux/console.h>
21#include <linux/rtc.h>
22#include <linux/init.h>
23#include <linux/vt_kern.h>
24#include <linux/delay.h>
25#include <linux/interrupt.h>
26#ifdef CONFIG_ZORRO
27#include <linux/zorro.h>
28#endif
29
30#include <asm/bootinfo.h>
31#include <asm/setup.h>
32#include <asm/system.h>
33#include <asm/pgtable.h>
34#include <asm/amigahw.h>
35#include <asm/amigaints.h>
36#include <asm/irq.h>
37#include <asm/rtc.h>
38#include <asm/machdep.h>
39#include <asm/io.h>
40
41unsigned long amiga_model;
42unsigned long amiga_eclock;
43unsigned long amiga_masterclock;
44unsigned long amiga_colorclock;
45unsigned long amiga_chipset;
46unsigned char amiga_vblank;
47unsigned char amiga_psfreq;
48struct amiga_hw_present amiga_hw_present;
49
50static char s_a500[] __initdata = "A500";
51static char s_a500p[] __initdata = "A500+";
52static char s_a600[] __initdata = "A600";
53static char s_a1000[] __initdata = "A1000";
54static char s_a1200[] __initdata = "A1200";
55static char s_a2000[] __initdata = "A2000";
56static char s_a2500[] __initdata = "A2500";
57static char s_a3000[] __initdata = "A3000";
58static char s_a3000t[] __initdata = "A3000T";
59static char s_a3000p[] __initdata = "A3000+";
60static char s_a4000[] __initdata = "A4000";
61static char s_a4000t[] __initdata = "A4000T";
62static char s_cdtv[] __initdata = "CDTV";
63static char s_cd32[] __initdata = "CD32";
64static char s_draco[] __initdata = "Draco";
65static char *amiga_models[] __initdata = {
66 [AMI_500-AMI_500] = s_a500,
67 [AMI_500PLUS-AMI_500] = s_a500p,
68 [AMI_600-AMI_500] = s_a600,
69 [AMI_1000-AMI_500] = s_a1000,
70 [AMI_1200-AMI_500] = s_a1200,
71 [AMI_2000-AMI_500] = s_a2000,
72 [AMI_2500-AMI_500] = s_a2500,
73 [AMI_3000-AMI_500] = s_a3000,
74 [AMI_3000T-AMI_500] = s_a3000t,
75 [AMI_3000PLUS-AMI_500] = s_a3000p,
76 [AMI_4000-AMI_500] = s_a4000,
77 [AMI_4000T-AMI_500] = s_a4000t,
78 [AMI_CDTV-AMI_500] = s_cdtv,
79 [AMI_CD32-AMI_500] = s_cd32,
80 [AMI_DRACO-AMI_500] = s_draco,
81};
82
83static char amiga_model_name[13] = "Amiga ";
84
85extern char m68k_debug_device[];
86
87static void amiga_sched_init(irqreturn_t (*handler)(int, void *, struct pt_regs *));
88/* amiga specific irq functions */
89extern void amiga_init_IRQ (void);
90extern irqreturn_t (*amiga_default_handler[]) (int, void *, struct pt_regs *);
91extern int amiga_request_irq (unsigned int irq,
92 irqreturn_t (*handler)(int, void *, struct pt_regs *),
93 unsigned long flags, const char *devname,
94 void *dev_id);
95extern void amiga_free_irq (unsigned int irq, void *dev_id);
96extern void amiga_enable_irq (unsigned int);
97extern void amiga_disable_irq (unsigned int);
98static void amiga_get_model(char *model);
99static int amiga_get_hardware_list(char *buffer);
100extern int show_amiga_interrupts (struct seq_file *, void *);
101/* amiga specific timer functions */
102static unsigned long amiga_gettimeoffset (void);
103static int a3000_hwclk (int, struct rtc_time *);
104static int a2000_hwclk (int, struct rtc_time *);
105static int amiga_set_clock_mmss (unsigned long);
106static unsigned int amiga_get_ss (void);
107extern void amiga_mksound( unsigned int count, unsigned int ticks );
108#ifdef CONFIG_AMIGA_FLOPPY
109extern void amiga_floppy_setup(char *, int *);
110#endif
111static void amiga_reset (void);
112extern void amiga_init_sound(void);
113static void amiga_savekmsg_init(void);
114static void amiga_mem_console_write(struct console *co, const char *b,
115 unsigned int count);
116void amiga_serial_console_write(struct console *co, const char *s,
117 unsigned int count);
118static void amiga_debug_init(void);
119#ifdef CONFIG_HEARTBEAT
120static void amiga_heartbeat(int on);
121#endif
122
123static struct console amiga_console_driver = {
124 .name = "debug",
125 .flags = CON_PRINTBUFFER,
126 .index = -1,
127};
128
129
130 /*
131 * Motherboard Resources present in all Amiga models
132 */
133
134static struct {
135 struct resource _ciab, _ciaa, _custom, _kickstart;
136} mb_resources = {
137 ._ciab = {
138 .name = "CIA B", .start = 0x00bfd000, .end = 0x00bfdfff
139 },
140 ._ciaa = {
141 .name = "CIA A", .start = 0x00bfe000, .end = 0x00bfefff
142 },
143 ._custom = {
144 .name = "Custom I/O", .start = 0x00dff000, .end = 0x00dfffff
145 },
146 ._kickstart = {
147 .name = "Kickstart ROM", .start = 0x00f80000, .end = 0x00ffffff
148 }
149};
150
151static struct resource rtc_resource = {
152 .start = 0x00dc0000, .end = 0x00dcffff
153};
154
155static struct resource ram_resource[NUM_MEMINFO];
156
157
158 /*
159 * Parse an Amiga-specific record in the bootinfo
160 */
161
162int amiga_parse_bootinfo(const struct bi_record *record)
163{
164 int unknown = 0;
165 const unsigned long *data = record->data;
166
167 switch (record->tag) {
168 case BI_AMIGA_MODEL:
169 amiga_model = *data;
170 break;
171
172 case BI_AMIGA_ECLOCK:
173 amiga_eclock = *data;
174 break;
175
176 case BI_AMIGA_CHIPSET:
177 amiga_chipset = *data;
178 break;
179
180 case BI_AMIGA_CHIP_SIZE:
181 amiga_chip_size = *(const int *)data;
182 break;
183
184 case BI_AMIGA_VBLANK:
185 amiga_vblank = *(const unsigned char *)data;
186 break;
187
188 case BI_AMIGA_PSFREQ:
189 amiga_psfreq = *(const unsigned char *)data;
190 break;
191
192 case BI_AMIGA_AUTOCON:
193#ifdef CONFIG_ZORRO
194 if (zorro_num_autocon < ZORRO_NUM_AUTO) {
195 const struct ConfigDev *cd = (struct ConfigDev *)data;
196 struct zorro_dev *dev = &zorro_autocon[zorro_num_autocon++];
197 dev->rom = cd->cd_Rom;
198 dev->slotaddr = cd->cd_SlotAddr;
199 dev->slotsize = cd->cd_SlotSize;
200 dev->resource.start = (unsigned long)cd->cd_BoardAddr;
201 dev->resource.end = dev->resource.start+cd->cd_BoardSize-1;
202 } else
203 printk("amiga_parse_bootinfo: too many AutoConfig devices\n");
204#endif /* CONFIG_ZORRO */
205 break;
206
207 case BI_AMIGA_SERPER:
208 /* serial port period: ignored here */
209 break;
210
211 default:
212 unknown = 1;
213 }
214 return(unknown);
215}
216
217 /*
218 * Identify builtin hardware
219 */
220
221static void __init amiga_identify(void)
222{
223 /* Fill in some default values, if necessary */
224 if (amiga_eclock == 0)
225 amiga_eclock = 709379;
226
227 memset(&amiga_hw_present, 0, sizeof(amiga_hw_present));
228
229 printk("Amiga hardware found: ");
230 if (amiga_model >= AMI_500 && amiga_model <= AMI_DRACO) {
231 printk("[%s] ", amiga_models[amiga_model-AMI_500]);
232 strcat(amiga_model_name, amiga_models[amiga_model-AMI_500]);
233 }
234
235 switch(amiga_model) {
236 case AMI_UNKNOWN:
237 goto Generic;
238
239 case AMI_600:
240 case AMI_1200:
241 AMIGAHW_SET(A1200_IDE);
242 AMIGAHW_SET(PCMCIA);
243 case AMI_500:
244 case AMI_500PLUS:
245 case AMI_1000:
246 case AMI_2000:
247 case AMI_2500:
248 AMIGAHW_SET(A2000_CLK); /* Is this correct for all models? */
249 goto Generic;
250
251 case AMI_3000:
252 case AMI_3000T:
253 AMIGAHW_SET(AMBER_FF);
254 AMIGAHW_SET(MAGIC_REKICK);
255 /* fall through */
256 case AMI_3000PLUS:
257 AMIGAHW_SET(A3000_SCSI);
258 AMIGAHW_SET(A3000_CLK);
259 AMIGAHW_SET(ZORRO3);
260 goto Generic;
261
262 case AMI_4000T:
263 AMIGAHW_SET(A4000_SCSI);
264 /* fall through */
265 case AMI_4000:
266 AMIGAHW_SET(A4000_IDE);
267 AMIGAHW_SET(A3000_CLK);
268 AMIGAHW_SET(ZORRO3);
269 goto Generic;
270
271 case AMI_CDTV:
272 case AMI_CD32:
273 AMIGAHW_SET(CD_ROM);
274 AMIGAHW_SET(A2000_CLK); /* Is this correct? */
275 goto Generic;
276
277 Generic:
278 AMIGAHW_SET(AMI_VIDEO);
279 AMIGAHW_SET(AMI_BLITTER);
280 AMIGAHW_SET(AMI_AUDIO);
281 AMIGAHW_SET(AMI_FLOPPY);
282 AMIGAHW_SET(AMI_KEYBOARD);
283 AMIGAHW_SET(AMI_MOUSE);
284 AMIGAHW_SET(AMI_SERIAL);
285 AMIGAHW_SET(AMI_PARALLEL);
286 AMIGAHW_SET(CHIP_RAM);
287 AMIGAHW_SET(PAULA);
288
289 switch(amiga_chipset) {
290 case CS_OCS:
291 case CS_ECS:
292 case CS_AGA:
293 switch (custom.deniseid & 0xf) {
294 case 0x0c:
295 AMIGAHW_SET(DENISE_HR);
296 break;
297 case 0x08:
298 AMIGAHW_SET(LISA);
299 break;
300 }
301 break;
302 default:
303 AMIGAHW_SET(DENISE);
304 break;
305 }
306 switch ((custom.vposr>>8) & 0x7f) {
307 case 0x00:
308 AMIGAHW_SET(AGNUS_PAL);
309 break;
310 case 0x10:
311 AMIGAHW_SET(AGNUS_NTSC);
312 break;
313 case 0x20:
314 case 0x21:
315 AMIGAHW_SET(AGNUS_HR_PAL);
316 break;
317 case 0x30:
318 case 0x31:
319 AMIGAHW_SET(AGNUS_HR_NTSC);
320 break;
321 case 0x22:
322 case 0x23:
323 AMIGAHW_SET(ALICE_PAL);
324 break;
325 case 0x32:
326 case 0x33:
327 AMIGAHW_SET(ALICE_NTSC);
328 break;
329 }
330 AMIGAHW_SET(ZORRO);
331 break;
332
333 case AMI_DRACO:
334 panic("No support for Draco yet");
335
336 default:
337 panic("Unknown Amiga Model");
338 }
339
340#define AMIGAHW_ANNOUNCE(name, str) \
341 if (AMIGAHW_PRESENT(name)) \
342 printk(str)
343
344 AMIGAHW_ANNOUNCE(AMI_VIDEO, "VIDEO ");
345 AMIGAHW_ANNOUNCE(AMI_BLITTER, "BLITTER ");
346 AMIGAHW_ANNOUNCE(AMBER_FF, "AMBER_FF ");
347 AMIGAHW_ANNOUNCE(AMI_AUDIO, "AUDIO ");
348 AMIGAHW_ANNOUNCE(AMI_FLOPPY, "FLOPPY ");
349 AMIGAHW_ANNOUNCE(A3000_SCSI, "A3000_SCSI ");
350 AMIGAHW_ANNOUNCE(A4000_SCSI, "A4000_SCSI ");
351 AMIGAHW_ANNOUNCE(A1200_IDE, "A1200_IDE ");
352 AMIGAHW_ANNOUNCE(A4000_IDE, "A4000_IDE ");
353 AMIGAHW_ANNOUNCE(CD_ROM, "CD_ROM ");
354 AMIGAHW_ANNOUNCE(AMI_KEYBOARD, "KEYBOARD ");
355 AMIGAHW_ANNOUNCE(AMI_MOUSE, "MOUSE ");
356 AMIGAHW_ANNOUNCE(AMI_SERIAL, "SERIAL ");
357 AMIGAHW_ANNOUNCE(AMI_PARALLEL, "PARALLEL ");
358 AMIGAHW_ANNOUNCE(A2000_CLK, "A2000_CLK ");
359 AMIGAHW_ANNOUNCE(A3000_CLK, "A3000_CLK ");
360 AMIGAHW_ANNOUNCE(CHIP_RAM, "CHIP_RAM ");
361 AMIGAHW_ANNOUNCE(PAULA, "PAULA ");
362 AMIGAHW_ANNOUNCE(DENISE, "DENISE ");
363 AMIGAHW_ANNOUNCE(DENISE_HR, "DENISE_HR ");
364 AMIGAHW_ANNOUNCE(LISA, "LISA ");
365 AMIGAHW_ANNOUNCE(AGNUS_PAL, "AGNUS_PAL ");
366 AMIGAHW_ANNOUNCE(AGNUS_NTSC, "AGNUS_NTSC ");
367 AMIGAHW_ANNOUNCE(AGNUS_HR_PAL, "AGNUS_HR_PAL ");
368 AMIGAHW_ANNOUNCE(AGNUS_HR_NTSC, "AGNUS_HR_NTSC ");
369 AMIGAHW_ANNOUNCE(ALICE_PAL, "ALICE_PAL ");
370 AMIGAHW_ANNOUNCE(ALICE_NTSC, "ALICE_NTSC ");
371 AMIGAHW_ANNOUNCE(MAGIC_REKICK, "MAGIC_REKICK ");
372 AMIGAHW_ANNOUNCE(PCMCIA, "PCMCIA ");
373 if (AMIGAHW_PRESENT(ZORRO))
374 printk("ZORRO%s ", AMIGAHW_PRESENT(ZORRO3) ? "3" : "");
375 printk("\n");
376
377#undef AMIGAHW_ANNOUNCE
378}
379
380 /*
381 * Setup the Amiga configuration info
382 */
383
384void __init config_amiga(void)
385{
386 int i;
387
388 amiga_debug_init();
389 amiga_identify();
390
391 /* Yuk, we don't have PCI memory */
392 iomem_resource.name = "Memory";
393 for (i = 0; i < 4; i++)
394 request_resource(&iomem_resource, &((struct resource *)&mb_resources)[i]);
395
396 mach_sched_init = amiga_sched_init;
397 mach_init_IRQ = amiga_init_IRQ;
398 mach_default_handler = &amiga_default_handler;
399 mach_request_irq = amiga_request_irq;
400 mach_free_irq = amiga_free_irq;
401 enable_irq = amiga_enable_irq;
402 disable_irq = amiga_disable_irq;
403 mach_get_model = amiga_get_model;
404 mach_get_hardware_list = amiga_get_hardware_list;
405 mach_get_irq_list = show_amiga_interrupts;
406 mach_gettimeoffset = amiga_gettimeoffset;
407 if (AMIGAHW_PRESENT(A3000_CLK)){
408 mach_hwclk = a3000_hwclk;
409 rtc_resource.name = "A3000 RTC";
410 request_resource(&iomem_resource, &rtc_resource);
411 }
412 else{ /* if (AMIGAHW_PRESENT(A2000_CLK)) */
413 mach_hwclk = a2000_hwclk;
414 rtc_resource.name = "A2000 RTC";
415 request_resource(&iomem_resource, &rtc_resource);
416 }
417
418 mach_max_dma_address = 0xffffffff; /*
419 * default MAX_DMA=0xffffffff
420 * on all machines. If we don't
421 * do so, the SCSI code will not
422 * be able to allocate any mem
423 * for transfers, unless we are
424 * dealing with a Z2 mem only
425 * system. /Jes
426 */
427
428 mach_set_clock_mmss = amiga_set_clock_mmss;
429 mach_get_ss = amiga_get_ss;
430#ifdef CONFIG_AMIGA_FLOPPY
431 mach_floppy_setup = amiga_floppy_setup;
432#endif
433 mach_reset = amiga_reset;
434#ifdef CONFIG_DUMMY_CONSOLE
435 conswitchp = &dummy_con;
436#endif
437#if defined(CONFIG_INPUT_M68K_BEEP) || defined(CONFIG_INPUT_M68K_BEEP_MODULE)
438 mach_beep = amiga_mksound;
439#endif
440
441#ifdef CONFIG_HEARTBEAT
442 mach_heartbeat = amiga_heartbeat;
443#endif
444
445 /* Fill in the clock values (based on the 700 kHz E-Clock) */
446 amiga_masterclock = 40*amiga_eclock; /* 28 MHz */
447 amiga_colorclock = 5*amiga_eclock; /* 3.5 MHz */
448
449 /* clear all DMA bits */
450 custom.dmacon = DMAF_ALL;
451 /* ensure that the DMA master bit is set */
452 custom.dmacon = DMAF_SETCLR | DMAF_MASTER;
453
454 /* don't use Z2 RAM as system memory on Z3 capable machines */
455 if (AMIGAHW_PRESENT(ZORRO3)) {
456 int i, j;
457 u32 disabled_z2mem = 0;
458 for (i = 0; i < m68k_num_memory; i++)
459 if (m68k_memory[i].addr < 16*1024*1024) {
460 if (i == 0) {
461 /* don't cut off the branch we're sitting on */
462 printk("Warning: kernel runs in Zorro II memory\n");
463 continue;
464 }
465 disabled_z2mem += m68k_memory[i].size;
466 m68k_num_memory--;
467 for (j = i; j < m68k_num_memory; j++)
468 m68k_memory[j] = m68k_memory[j+1];
469 i--;
470 }
471 if (disabled_z2mem)
472 printk("%dK of Zorro II memory will not be used as system memory\n",
473 disabled_z2mem>>10);
474 }
475
476 /* request all RAM */
477 for (i = 0; i < m68k_num_memory; i++) {
478 ram_resource[i].name =
479 (m68k_memory[i].addr >= 0x01000000) ? "32-bit Fast RAM" :
480 (m68k_memory[i].addr < 0x00c00000) ? "16-bit Fast RAM" :
481 "16-bit Slow RAM";
482 ram_resource[i].start = m68k_memory[i].addr;
483 ram_resource[i].end = m68k_memory[i].addr+m68k_memory[i].size-1;
484 request_resource(&iomem_resource, &ram_resource[i]);
485 }
486
487 /* initialize chipram allocator */
488 amiga_chip_init ();
489
490 /* debugging using chipram */
491 if (!strcmp( m68k_debug_device, "mem" )){
492 if (!AMIGAHW_PRESENT(CHIP_RAM))
493 printk("Warning: no chipram present for debugging\n");
494 else {
495 amiga_savekmsg_init();
496 amiga_console_driver.write = amiga_mem_console_write;
497 register_console(&amiga_console_driver);
498 }
499 }
500
501 /* our beloved beeper */
502 if (AMIGAHW_PRESENT(AMI_AUDIO))
503 amiga_init_sound();
504
505 /*
506 * if it is an A3000, set the magic bit that forces
507 * a hard rekick
508 */
509 if (AMIGAHW_PRESENT(MAGIC_REKICK))
510 *(unsigned char *)ZTWO_VADDR(0xde0002) |= 0x80;
511}
512
513static unsigned short jiffy_ticks;
514
515static void __init amiga_sched_init(irqreturn_t (*timer_routine)(int, void *,
516 struct pt_regs *))
517{
518 static struct resource sched_res = {
519 .name = "timer", .start = 0x00bfd400, .end = 0x00bfd5ff,
520 };
521 jiffy_ticks = (amiga_eclock+HZ/2)/HZ;
522
523 if (request_resource(&mb_resources._ciab, &sched_res))
524 printk("Cannot allocate ciab.ta{lo,hi}\n");
525 ciab.cra &= 0xC0; /* turn off timer A, continuous mode, from Eclk */
526 ciab.talo = jiffy_ticks % 256;
527 ciab.tahi = jiffy_ticks / 256;
528
529 /* install interrupt service routine for CIAB Timer A
530 *
531 * Please don't change this to use ciaa, as it interferes with the
532 * SCSI code. We'll have to take a look at this later
533 */
534 request_irq(IRQ_AMIGA_CIAB_TA, timer_routine, 0, "timer", NULL);
535 /* start timer */
536 ciab.cra |= 0x11;
537}
538
539#define TICK_SIZE 10000
540
541/* This is always executed with interrupts disabled. */
542static unsigned long amiga_gettimeoffset (void)
543{
544 unsigned short hi, lo, hi2;
545 unsigned long ticks, offset = 0;
546
547 /* read CIA B timer A current value */
548 hi = ciab.tahi;
549 lo = ciab.talo;
550 hi2 = ciab.tahi;
551
552 if (hi != hi2) {
553 lo = ciab.talo;
554 hi = hi2;
555 }
556
557 ticks = hi << 8 | lo;
558
559 if (ticks > jiffy_ticks / 2)
560 /* check for pending interrupt */
561 if (cia_set_irq(&ciab_base, 0) & CIA_ICR_TA)
562 offset = 10000;
563
564 ticks = jiffy_ticks - ticks;
565 ticks = (10000 * ticks) / jiffy_ticks;
566
567 return ticks + offset;
568}
569
570static int a3000_hwclk(int op, struct rtc_time *t)
571{
572 tod_3000.cntrl1 = TOD3000_CNTRL1_HOLD;
573
574 if (!op) { /* read */
575 t->tm_sec = tod_3000.second1 * 10 + tod_3000.second2;
576 t->tm_min = tod_3000.minute1 * 10 + tod_3000.minute2;
577 t->tm_hour = tod_3000.hour1 * 10 + tod_3000.hour2;
578 t->tm_mday = tod_3000.day1 * 10 + tod_3000.day2;
579 t->tm_wday = tod_3000.weekday;
580 t->tm_mon = tod_3000.month1 * 10 + tod_3000.month2 - 1;
581 t->tm_year = tod_3000.year1 * 10 + tod_3000.year2;
582 if (t->tm_year <= 69)
583 t->tm_year += 100;
584 } else {
585 tod_3000.second1 = t->tm_sec / 10;
586 tod_3000.second2 = t->tm_sec % 10;
587 tod_3000.minute1 = t->tm_min / 10;
588 tod_3000.minute2 = t->tm_min % 10;
589 tod_3000.hour1 = t->tm_hour / 10;
590 tod_3000.hour2 = t->tm_hour % 10;
591 tod_3000.day1 = t->tm_mday / 10;
592 tod_3000.day2 = t->tm_mday % 10;
593 if (t->tm_wday != -1)
594 tod_3000.weekday = t->tm_wday;
595 tod_3000.month1 = (t->tm_mon + 1) / 10;
596 tod_3000.month2 = (t->tm_mon + 1) % 10;
597 if (t->tm_year >= 100)
598 t->tm_year -= 100;
599 tod_3000.year1 = t->tm_year / 10;
600 tod_3000.year2 = t->tm_year % 10;
601 }
602
603 tod_3000.cntrl1 = TOD3000_CNTRL1_FREE;
604
605 return 0;
606}
607
608static int a2000_hwclk(int op, struct rtc_time *t)
609{
610 int cnt = 5;
611
612 tod_2000.cntrl1 = TOD2000_CNTRL1_HOLD;
613
614 while ((tod_2000.cntrl1 & TOD2000_CNTRL1_BUSY) && cnt--)
615 {
616 tod_2000.cntrl1 &= ~TOD2000_CNTRL1_HOLD;
617 udelay(70);
618 tod_2000.cntrl1 |= TOD2000_CNTRL1_HOLD;
619 }
620
621 if (!cnt)
622 printk(KERN_INFO "hwclk: timed out waiting for RTC (0x%x)\n", tod_2000.cntrl1);
623
624 if (!op) { /* read */
625 t->tm_sec = tod_2000.second1 * 10 + tod_2000.second2;
626 t->tm_min = tod_2000.minute1 * 10 + tod_2000.minute2;
627 t->tm_hour = (tod_2000.hour1 & 3) * 10 + tod_2000.hour2;
628 t->tm_mday = tod_2000.day1 * 10 + tod_2000.day2;
629 t->tm_wday = tod_2000.weekday;
630 t->tm_mon = tod_2000.month1 * 10 + tod_2000.month2 - 1;
631 t->tm_year = tod_2000.year1 * 10 + tod_2000.year2;
632 if (t->tm_year <= 69)
633 t->tm_year += 100;
634
635 if (!(tod_2000.cntrl3 & TOD2000_CNTRL3_24HMODE)){
636 if (!(tod_2000.hour1 & TOD2000_HOUR1_PM) && t->tm_hour == 12)
637 t->tm_hour = 0;
638 else if ((tod_2000.hour1 & TOD2000_HOUR1_PM) && t->tm_hour != 12)
639 t->tm_hour += 12;
640 }
641 } else {
642 tod_2000.second1 = t->tm_sec / 10;
643 tod_2000.second2 = t->tm_sec % 10;
644 tod_2000.minute1 = t->tm_min / 10;
645 tod_2000.minute2 = t->tm_min % 10;
646 if (tod_2000.cntrl3 & TOD2000_CNTRL3_24HMODE)
647 tod_2000.hour1 = t->tm_hour / 10;
648 else if (t->tm_hour >= 12)
649 tod_2000.hour1 = TOD2000_HOUR1_PM +
650 (t->tm_hour - 12) / 10;
651 else
652 tod_2000.hour1 = t->tm_hour / 10;
653 tod_2000.hour2 = t->tm_hour % 10;
654 tod_2000.day1 = t->tm_mday / 10;
655 tod_2000.day2 = t->tm_mday % 10;
656 if (t->tm_wday != -1)
657 tod_2000.weekday = t->tm_wday;
658 tod_2000.month1 = (t->tm_mon + 1) / 10;
659 tod_2000.month2 = (t->tm_mon + 1) % 10;
660 if (t->tm_year >= 100)
661 t->tm_year -= 100;
662 tod_2000.year1 = t->tm_year / 10;
663 tod_2000.year2 = t->tm_year % 10;
664 }
665
666 tod_2000.cntrl1 &= ~TOD2000_CNTRL1_HOLD;
667
668 return 0;
669}
670
671static int amiga_set_clock_mmss (unsigned long nowtime)
672{
673 short real_seconds = nowtime % 60, real_minutes = (nowtime / 60) % 60;
674
675 if (AMIGAHW_PRESENT(A3000_CLK)) {
676 tod_3000.cntrl1 = TOD3000_CNTRL1_HOLD;
677
678 tod_3000.second1 = real_seconds / 10;
679 tod_3000.second2 = real_seconds % 10;
680 tod_3000.minute1 = real_minutes / 10;
681 tod_3000.minute2 = real_minutes % 10;
682
683 tod_3000.cntrl1 = TOD3000_CNTRL1_FREE;
684 } else /* if (AMIGAHW_PRESENT(A2000_CLK)) */ {
685 int cnt = 5;
686
687 tod_2000.cntrl1 |= TOD2000_CNTRL1_HOLD;
688
689 while ((tod_2000.cntrl1 & TOD2000_CNTRL1_BUSY) && cnt--)
690 {
691 tod_2000.cntrl1 &= ~TOD2000_CNTRL1_HOLD;
692 udelay(70);
693 tod_2000.cntrl1 |= TOD2000_CNTRL1_HOLD;
694 }
695
696 if (!cnt)
697 printk(KERN_INFO "set_clock_mmss: timed out waiting for RTC (0x%x)\n", tod_2000.cntrl1);
698
699 tod_2000.second1 = real_seconds / 10;
700 tod_2000.second2 = real_seconds % 10;
701 tod_2000.minute1 = real_minutes / 10;
702 tod_2000.minute2 = real_minutes % 10;
703
704 tod_2000.cntrl1 &= ~TOD2000_CNTRL1_HOLD;
705 }
706
707 return 0;
708}
709
710static unsigned int amiga_get_ss( void )
711{
712 unsigned int s;
713
714 if (AMIGAHW_PRESENT(A3000_CLK)) {
715 tod_3000.cntrl1 = TOD3000_CNTRL1_HOLD;
716 s = tod_3000.second1 * 10 + tod_3000.second2;
717 tod_3000.cntrl1 = TOD3000_CNTRL1_FREE;
718 } else /* if (AMIGAHW_PRESENT(A2000_CLK)) */ {
719 s = tod_2000.second1 * 10 + tod_2000.second2;
720 }
721 return s;
722}
723
724static NORET_TYPE void amiga_reset( void )
725 ATTRIB_NORET;
726
727static void amiga_reset (void)
728{
729 unsigned long jmp_addr040 = virt_to_phys(&&jmp_addr_label040);
730 unsigned long jmp_addr = virt_to_phys(&&jmp_addr_label);
731
732 local_irq_disable();
733 if (CPU_IS_040_OR_060)
734 /* Setup transparent translation registers for mapping
735 * of 16 MB kernel segment before disabling translation
736 */
737 __asm__ __volatile__
738 ("movel %0,%/d0\n\t"
739 "andl #0xff000000,%/d0\n\t"
740 "orw #0xe020,%/d0\n\t" /* map 16 MB, enable, cacheable */
741 ".chip 68040\n\t"
742 "movec %%d0,%%itt0\n\t"
743 "movec %%d0,%%dtt0\n\t"
744 ".chip 68k\n\t"
745 "jmp %0@\n\t"
746 : /* no outputs */
747 : "a" (jmp_addr040));
748 else
749 /* for 680[23]0, just disable translation and jump to the physical
750 * address of the label
751 */
752 __asm__ __volatile__
753 ("pmove %/tc,%@\n\t"
754 "bclr #7,%@\n\t"
755 "pmove %@,%/tc\n\t"
756 "jmp %0@\n\t"
757 : /* no outputs */
758 : "a" (jmp_addr));
759 jmp_addr_label040:
760 /* disable translation on '040 now */
761 __asm__ __volatile__
762 ("moveq #0,%/d0\n\t"
763 ".chip 68040\n\t"
764 "movec %%d0,%%tc\n\t" /* disable MMU */
765 ".chip 68k\n\t"
766 : /* no outputs */
767 : /* no inputs */
768 : "d0");
769
770 jmp_addr_label:
771 /* pickup reset address from AmigaOS ROM, reset devices and jump
772 * to reset address
773 */
774 __asm__ __volatile__
775 ("movew #0x2700,%/sr\n\t"
776 "leal 0x01000000,%/a0\n\t"
777 "subl %/a0@(-0x14),%/a0\n\t"
778 "movel %/a0@(4),%/a0\n\t"
779 "subql #2,%/a0\n\t"
780 "bra 1f\n\t"
781 /* align on a longword boundary */
782 __ALIGN_STR "\n"
783 "1:\n\t"
784 "reset\n\t"
785 "jmp %/a0@" : /* Just that gcc scans it for % escapes */ );
786
787 for (;;);
788
789}
790
791
792 /*
793 * Debugging
794 */
795
796#define SAVEKMSG_MAXMEM 128*1024
797
798#define SAVEKMSG_MAGIC1 0x53415645 /* 'SAVE' */
799#define SAVEKMSG_MAGIC2 0x4B4D5347 /* 'KMSG' */
800
801struct savekmsg {
802 unsigned long magic1; /* SAVEKMSG_MAGIC1 */
803 unsigned long magic2; /* SAVEKMSG_MAGIC2 */
804 unsigned long magicptr; /* address of magic1 */
805 unsigned long size;
806 char data[0];
807};
808
809static struct savekmsg *savekmsg;
810
811static void amiga_mem_console_write(struct console *co, const char *s,
812 unsigned int count)
813{
814 if (savekmsg->size+count <= SAVEKMSG_MAXMEM-sizeof(struct savekmsg)) {
815 memcpy(savekmsg->data+savekmsg->size, s, count);
816 savekmsg->size += count;
817 }
818}
819
820static void amiga_savekmsg_init(void)
821{
822 static struct resource debug_res = { .name = "Debug" };
823
824 savekmsg = amiga_chip_alloc_res(SAVEKMSG_MAXMEM, &debug_res);
825 savekmsg->magic1 = SAVEKMSG_MAGIC1;
826 savekmsg->magic2 = SAVEKMSG_MAGIC2;
827 savekmsg->magicptr = ZTWO_PADDR(savekmsg);
828 savekmsg->size = 0;
829}
830
831static void amiga_serial_putc(char c)
832{
833 custom.serdat = (unsigned char)c | 0x100;
834 while (!(custom.serdatr & 0x2000))
835 ;
836}
837
838void amiga_serial_console_write(struct console *co, const char *s,
839 unsigned int count)
840{
841 while (count--) {
842 if (*s == '\n')
843 amiga_serial_putc('\r');
844 amiga_serial_putc(*s++);
845 }
846}
847
848#ifdef CONFIG_SERIAL_CONSOLE
849void amiga_serial_puts(const char *s)
850{
851 amiga_serial_console_write(NULL, s, strlen(s));
852}
853
854int amiga_serial_console_wait_key(struct console *co)
855{
856 int ch;
857
858 while (!(custom.intreqr & IF_RBF))
859 barrier();
860 ch = custom.serdatr & 0xff;
861 /* clear the interrupt, so that another character can be read */
862 custom.intreq = IF_RBF;
863 return ch;
864}
865
866void amiga_serial_gets(struct console *co, char *s, int len)
867{
868 int ch, cnt = 0;
869
870 while (1) {
871 ch = amiga_serial_console_wait_key(co);
872
873 /* Check for backspace. */
874 if (ch == 8 || ch == 127) {
875 if (cnt == 0) {
876 amiga_serial_putc('\007');
877 continue;
878 }
879 cnt--;
880 amiga_serial_puts("\010 \010");
881 continue;
882 }
883
884 /* Check for enter. */
885 if (ch == 10 || ch == 13)
886 break;
887
888 /* See if line is too long. */
889 if (cnt >= len + 1) {
890 amiga_serial_putc(7);
891 cnt--;
892 continue;
893 }
894
895 /* Store and echo character. */
896 s[cnt++] = ch;
897 amiga_serial_putc(ch);
898 }
899 /* Print enter. */
900 amiga_serial_puts("\r\n");
901 s[cnt] = 0;
902}
903#endif
904
905static void __init amiga_debug_init(void)
906{
907 if (!strcmp( m68k_debug_device, "ser" )) {
908 /* no initialization required (?) */
909 amiga_console_driver.write = amiga_serial_console_write;
910 register_console(&amiga_console_driver);
911 }
912}
913
914#ifdef CONFIG_HEARTBEAT
915static void amiga_heartbeat(int on)
916{
917 if (on)
918 ciaa.pra &= ~2;
919 else
920 ciaa.pra |= 2;
921}
922#endif
923
924 /*
925 * Amiga specific parts of /proc
926 */
927
928static void amiga_get_model(char *model)
929{
930 strcpy(model, amiga_model_name);
931}
932
933
934static int amiga_get_hardware_list(char *buffer)
935{
936 int len = 0;
937
938 if (AMIGAHW_PRESENT(CHIP_RAM))
939 len += sprintf(buffer+len, "Chip RAM:\t%ldK\n", amiga_chip_size>>10);
940 len += sprintf(buffer+len, "PS Freq:\t%dHz\nEClock Freq:\t%ldHz\n",
941 amiga_psfreq, amiga_eclock);
942 if (AMIGAHW_PRESENT(AMI_VIDEO)) {
943 char *type;
944 switch(amiga_chipset) {
945 case CS_OCS:
946 type = "OCS";
947 break;
948 case CS_ECS:
949 type = "ECS";
950 break;
951 case CS_AGA:
952 type = "AGA";
953 break;
954 default:
955 type = "Old or Unknown";
956 break;
957 }
958 len += sprintf(buffer+len, "Graphics:\t%s\n", type);
959 }
960
961#define AMIGAHW_ANNOUNCE(name, str) \
962 if (AMIGAHW_PRESENT(name)) \
963 len += sprintf (buffer+len, "\t%s\n", str)
964
965 len += sprintf (buffer + len, "Detected hardware:\n");
966
967 AMIGAHW_ANNOUNCE(AMI_VIDEO, "Amiga Video");
968 AMIGAHW_ANNOUNCE(AMI_BLITTER, "Blitter");
969 AMIGAHW_ANNOUNCE(AMBER_FF, "Amber Flicker Fixer");
970 AMIGAHW_ANNOUNCE(AMI_AUDIO, "Amiga Audio");
971 AMIGAHW_ANNOUNCE(AMI_FLOPPY, "Floppy Controller");
972 AMIGAHW_ANNOUNCE(A3000_SCSI, "SCSI Controller WD33C93 (A3000 style)");
973 AMIGAHW_ANNOUNCE(A4000_SCSI, "SCSI Controller NCR53C710 (A4000T style)");
974 AMIGAHW_ANNOUNCE(A1200_IDE, "IDE Interface (A1200 style)");
975 AMIGAHW_ANNOUNCE(A4000_IDE, "IDE Interface (A4000 style)");
976 AMIGAHW_ANNOUNCE(CD_ROM, "Internal CD ROM drive");
977 AMIGAHW_ANNOUNCE(AMI_KEYBOARD, "Keyboard");
978 AMIGAHW_ANNOUNCE(AMI_MOUSE, "Mouse Port");
979 AMIGAHW_ANNOUNCE(AMI_SERIAL, "Serial Port");
980 AMIGAHW_ANNOUNCE(AMI_PARALLEL, "Parallel Port");
981 AMIGAHW_ANNOUNCE(A2000_CLK, "Hardware Clock (A2000 style)");
982 AMIGAHW_ANNOUNCE(A3000_CLK, "Hardware Clock (A3000 style)");
983 AMIGAHW_ANNOUNCE(CHIP_RAM, "Chip RAM");
984 AMIGAHW_ANNOUNCE(PAULA, "Paula 8364");
985 AMIGAHW_ANNOUNCE(DENISE, "Denise 8362");
986 AMIGAHW_ANNOUNCE(DENISE_HR, "Denise 8373");
987 AMIGAHW_ANNOUNCE(LISA, "Lisa 8375");
988 AMIGAHW_ANNOUNCE(AGNUS_PAL, "Normal/Fat PAL Agnus 8367/8371");
989 AMIGAHW_ANNOUNCE(AGNUS_NTSC, "Normal/Fat NTSC Agnus 8361/8370");
990 AMIGAHW_ANNOUNCE(AGNUS_HR_PAL, "Fat Hires PAL Agnus 8372");
991 AMIGAHW_ANNOUNCE(AGNUS_HR_NTSC, "Fat Hires NTSC Agnus 8372");
992 AMIGAHW_ANNOUNCE(ALICE_PAL, "PAL Alice 8374");
993 AMIGAHW_ANNOUNCE(ALICE_NTSC, "NTSC Alice 8374");
994 AMIGAHW_ANNOUNCE(MAGIC_REKICK, "Magic Hard Rekick");
995 AMIGAHW_ANNOUNCE(PCMCIA, "PCMCIA Slot");
996#ifdef CONFIG_ZORRO
997 if (AMIGAHW_PRESENT(ZORRO))
998 len += sprintf(buffer+len, "\tZorro II%s AutoConfig: %d Expansion "
999 "Device%s\n",
1000 AMIGAHW_PRESENT(ZORRO3) ? "I" : "",
1001 zorro_num_autocon, zorro_num_autocon == 1 ? "" : "s");
1002#endif /* CONFIG_ZORRO */
1003
1004#undef AMIGAHW_ANNOUNCE
1005
1006 return(len);
1007}
diff --git a/arch/m68k/amiga/pcmcia.c b/arch/m68k/amiga/pcmcia.c
new file mode 100644
index 000000000000..fc57c6e72acf
--- /dev/null
+++ b/arch/m68k/amiga/pcmcia.c
@@ -0,0 +1,113 @@
1/*
2** asm-m68k/pcmcia.c -- Amiga Linux PCMCIA support
3** most information was found by disassembling card.resource
4** I'm still looking for an official doc !
5**
6** Copyright 1997 by Alain Malek
7**
8** This file is subject to the terms and conditions of the GNU General Public
9** License. See the file COPYING in the main directory of this archive
10** for more details.
11**
12** Created: 12/10/97 by Alain Malek
13*/
14
15#include <linux/types.h>
16#include <linux/jiffies.h>
17#include <linux/timer.h>
18#include <asm/amigayle.h>
19#include <asm/amipcmcia.h>
20
21/* gayle config byte for program voltage and access speed */
22static unsigned char cfg_byte = GAYLE_CFG_0V|GAYLE_CFG_150NS;
23
24void pcmcia_reset(void)
25{
26 unsigned long reset_start_time = jiffies;
27 unsigned char b;
28
29 gayle_reset = 0x00;
30 while (time_before(jiffies, reset_start_time + 1*HZ/100));
31 b = gayle_reset;
32}
33
34
35/* copy a tuple, including tuple header. return nb bytes copied */
36/* be carefull as this may trigger a GAYLE_IRQ_WR interrupt ! */
37
38int pcmcia_copy_tuple(unsigned char tuple_id, void *tuple, int max_len)
39{
40 unsigned char id, *dest;
41 int cnt, pos, len;
42
43 dest = tuple;
44 pos = 0;
45
46 id = gayle_attribute[pos];
47
48 while((id != CISTPL_END) && (pos < 0x10000)) {
49 len = (int)gayle_attribute[pos+2] + 2;
50 if (id == tuple_id) {
51 len = (len > max_len)?max_len:len;
52 for (cnt = 0; cnt < len; cnt++) {
53 *dest++ = gayle_attribute[pos+(cnt<<1)];
54 }
55
56 return len;
57 }
58 pos += len<<1;
59 id = gayle_attribute[pos];
60 }
61
62 return 0;
63}
64
65void pcmcia_program_voltage(int voltage)
66{
67 unsigned char v;
68
69 switch (voltage) {
70 case PCMCIA_0V:
71 v = GAYLE_CFG_0V;
72 break;
73 case PCMCIA_5V:
74 v = GAYLE_CFG_5V;
75 break;
76 case PCMCIA_12V:
77 v = GAYLE_CFG_12V;
78 break;
79 default:
80 v = GAYLE_CFG_0V;
81 }
82
83 cfg_byte = (cfg_byte & 0xfc) | v;
84 gayle.config = cfg_byte;
85
86}
87
88void pcmcia_access_speed(int speed)
89{
90 unsigned char s;
91
92 if (speed <= PCMCIA_SPEED_100NS)
93 s = GAYLE_CFG_100NS;
94 else if (speed <= PCMCIA_SPEED_150NS)
95 s = GAYLE_CFG_150NS;
96 else if (speed <= PCMCIA_SPEED_250NS)
97 s = GAYLE_CFG_250NS;
98 else
99 s = GAYLE_CFG_720NS;
100
101 cfg_byte = (cfg_byte & 0xf3) | s;
102 gayle.config = cfg_byte;
103}
104
105void pcmcia_write_enable(void)
106{
107 gayle.cardstatus = GAYLE_CS_WR|GAYLE_CS_DA;
108}
109
110void pcmcia_write_disable(void)
111{
112 gayle.cardstatus = 0;
113}