aboutsummaryrefslogtreecommitdiffstats
path: root/arch/ppc/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/ppc/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/ppc/amiga')
-rw-r--r--arch/ppc/amiga/Makefile8
-rw-r--r--arch/ppc/amiga/amiga_ksyms.c1
-rw-r--r--arch/ppc/amiga/amiints.c323
-rw-r--r--arch/ppc/amiga/amisound.c1
-rw-r--r--arch/ppc/amiga/bootinfo.c80
-rw-r--r--arch/ppc/amiga/chipram.c1
-rw-r--r--arch/ppc/amiga/cia.c178
-rw-r--r--arch/ppc/amiga/config.c962
-rw-r--r--arch/ppc/amiga/ints.c160
-rw-r--r--arch/ppc/amiga/pcmcia.c1
-rw-r--r--arch/ppc/amiga/time.c58
11 files changed, 1773 insertions, 0 deletions
diff --git a/arch/ppc/amiga/Makefile b/arch/ppc/amiga/Makefile
new file mode 100644
index 000000000000..59fec0a3ac8e
--- /dev/null
+++ b/arch/ppc/amiga/Makefile
@@ -0,0 +1,8 @@
1#
2# Makefile for Linux arch/m68k/amiga source directory
3#
4
5obj-y := config.o amiints.o cia.o time.o bootinfo.o amisound.o \
6 chipram.o amiga_ksyms.o
7
8obj-$(CONFIG_AMIGA_PCMCIA) += pcmcia.o
diff --git a/arch/ppc/amiga/amiga_ksyms.c b/arch/ppc/amiga/amiga_ksyms.c
new file mode 100644
index 000000000000..ec74e5b7a1ce
--- /dev/null
+++ b/arch/ppc/amiga/amiga_ksyms.c
@@ -0,0 +1 @@
#include "../../m68k/amiga/amiga_ksyms.c"
diff --git a/arch/ppc/amiga/amiints.c b/arch/ppc/amiga/amiints.c
new file mode 100644
index 000000000000..91195e2ce38d
--- /dev/null
+++ b/arch/ppc/amiga/amiints.c
@@ -0,0 +1,323 @@
1/*
2 * arch/ppc/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/config.h>
39#include <linux/types.h>
40#include <linux/kernel.h>
41#include <linux/sched.h>
42#include <linux/interrupt.h>
43#include <linux/irq.h>
44#include <linux/kernel_stat.h>
45#include <linux/init.h>
46
47#include <asm/system.h>
48#include <asm/irq.h>
49#include <asm/traps.h>
50#include <asm/amigahw.h>
51#include <asm/amigaints.h>
52#include <asm/amipcmcia.h>
53
54#ifdef CONFIG_APUS
55#include <asm/amigappc.h>
56#endif
57
58extern void cia_init_IRQ(struct ciabase *base);
59
60unsigned short ami_intena_vals[AMI_STD_IRQS] = {
61 IF_VERTB, IF_COPER, IF_AUD0, IF_AUD1, IF_AUD2, IF_AUD3, IF_BLIT,
62 IF_DSKSYN, IF_DSKBLK, IF_RBF, IF_TBE, IF_SOFT, IF_PORTS, IF_EXTER
63};
64static const unsigned char ami_servers[AMI_STD_IRQS] = {
65 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1
66};
67
68static short ami_ablecount[AMI_IRQS];
69
70static void ami_badint(int irq, void *dev_id, struct pt_regs *fp)
71{
72/* num_spurious += 1;*/
73}
74
75/*
76 * void amiga_init_IRQ(void)
77 *
78 * Parameters: None
79 *
80 * Returns: Nothing
81 *
82 * This function should be called during kernel startup to initialize
83 * the amiga IRQ handling routines.
84 */
85
86__init
87void amiga_init_IRQ(void)
88{
89 int i;
90
91 for (i = 0; i < AMI_IRQS; i++)
92 ami_ablecount[i] = 0;
93
94 /* turn off PCMCIA interrupts */
95 if (AMIGAHW_PRESENT(PCMCIA))
96 gayle.inten = GAYLE_IRQ_IDE;
97
98 /* turn off all interrupts... */
99 custom.intena = 0x7fff;
100 custom.intreq = 0x7fff;
101
102#ifdef CONFIG_APUS
103 /* Clear any inter-CPU interrupt requests. Circumvents bug in
104 Blizzard IPL emulation HW (or so it appears). */
105 APUS_WRITE(APUS_INT_LVL, INTLVL_SETRESET | INTLVL_MASK);
106
107 /* Init IPL emulation. */
108 APUS_WRITE(APUS_REG_INT, REGINT_INTMASTER | REGINT_ENABLEIPL);
109 APUS_WRITE(APUS_IPL_EMU, IPLEMU_DISABLEINT);
110 APUS_WRITE(APUS_IPL_EMU, IPLEMU_SETRESET | IPLEMU_IPLMASK);
111#endif
112 /* ... and enable the master interrupt bit */
113 custom.intena = IF_SETCLR | IF_INTEN;
114
115 cia_init_IRQ(&ciaa_base);
116 cia_init_IRQ(&ciab_base);
117}
118
119/*
120 * Enable/disable a particular machine specific interrupt source.
121 * Note that this may affect other interrupts in case of a shared interrupt.
122 * This function should only be called for a _very_ short time to change some
123 * internal data, that may not be changed by the interrupt at the same time.
124 * ami_(enable|disable)_irq calls may also be nested.
125 */
126
127void amiga_enable_irq(unsigned int irq)
128{
129 if (irq >= AMI_IRQS) {
130 printk("%s: Unknown IRQ %d\n", __FUNCTION__, irq);
131 return;
132 }
133
134 ami_ablecount[irq]--;
135 if (ami_ablecount[irq]<0)
136 ami_ablecount[irq]=0;
137 else if (ami_ablecount[irq])
138 return;
139
140 /* No action for auto-vector interrupts */
141 if (irq >= IRQ_AMIGA_AUTO){
142 printk("%s: Trying to enable auto-vector IRQ %i\n",
143 __FUNCTION__, irq - IRQ_AMIGA_AUTO);
144 return;
145 }
146
147 if (irq >= IRQ_AMIGA_CIAA) {
148 cia_set_irq(irq, 0);
149 cia_able_irq(irq, 1);
150 return;
151 }
152
153 /* enable the interrupt */
154 custom.intena = IF_SETCLR | ami_intena_vals[irq];
155}
156
157void amiga_disable_irq(unsigned int irq)
158{
159 if (irq >= AMI_IRQS) {
160 printk("%s: Unknown IRQ %d\n", __FUNCTION__, irq);
161 return;
162 }
163
164 if (ami_ablecount[irq]++)
165 return;
166
167 /* No action for auto-vector interrupts */
168 if (irq >= IRQ_AMIGA_AUTO) {
169 printk("%s: Trying to disable auto-vector IRQ %i\n",
170 __FUNCTION__, irq - IRQ_AMIGA_AUTO);
171 return;
172 }
173
174 if (irq >= IRQ_AMIGA_CIAA) {
175 cia_able_irq(irq, 0);
176 return;
177 }
178
179 /* disable the interrupt */
180 custom.intena = ami_intena_vals[irq];
181}
182
183inline void amiga_do_irq(int irq, struct pt_regs *fp)
184{
185 irq_desc_t *desc = irq_desc + irq;
186 struct irqaction *action = desc->action;
187
188 kstat_cpu(0).irqs[irq]++;
189 action->handler(irq, action->dev_id, fp);
190}
191
192void amiga_do_irq_list(int irq, struct pt_regs *fp)
193{
194 irq_desc_t *desc = irq_desc + irq;
195 struct irqaction *action;
196
197 kstat_cpu(0).irqs[irq]++;
198
199 custom.intreq = ami_intena_vals[irq];
200
201 for (action = desc->action; action; action = action->next)
202 action->handler(irq, action->dev_id, fp);
203}
204
205/*
206 * The builtin Amiga hardware interrupt handlers.
207 */
208
209static void ami_int1(int irq, void *dev_id, struct pt_regs *fp)
210{
211 unsigned short ints = custom.intreqr & custom.intenar;
212
213 /* if serial transmit buffer empty, interrupt */
214 if (ints & IF_TBE) {
215 custom.intreq = IF_TBE;
216 amiga_do_irq(IRQ_AMIGA_TBE, fp);
217 }
218
219 /* if floppy disk transfer complete, interrupt */
220 if (ints & IF_DSKBLK) {
221 custom.intreq = IF_DSKBLK;
222 amiga_do_irq(IRQ_AMIGA_DSKBLK, fp);
223 }
224
225 /* if software interrupt set, interrupt */
226 if (ints & IF_SOFT) {
227 custom.intreq = IF_SOFT;
228 amiga_do_irq(IRQ_AMIGA_SOFT, fp);
229 }
230}
231
232static void ami_int3(int irq, void *dev_id, struct pt_regs *fp)
233{
234 unsigned short ints = custom.intreqr & custom.intenar;
235
236 /* if a blitter interrupt */
237 if (ints & IF_BLIT) {
238 custom.intreq = IF_BLIT;
239 amiga_do_irq(IRQ_AMIGA_BLIT, fp);
240 }
241
242 /* if a copper interrupt */
243 if (ints & IF_COPER) {
244 custom.intreq = IF_COPER;
245 amiga_do_irq(IRQ_AMIGA_COPPER, fp);
246 }
247
248 /* if a vertical blank interrupt */
249 if (ints & IF_VERTB)
250 amiga_do_irq_list(IRQ_AMIGA_VERTB, fp);
251}
252
253static void ami_int4(int irq, void *dev_id, struct pt_regs *fp)
254{
255 unsigned short ints = custom.intreqr & custom.intenar;
256
257 /* if audio 0 interrupt */
258 if (ints & IF_AUD0) {
259 custom.intreq = IF_AUD0;
260 amiga_do_irq(IRQ_AMIGA_AUD0, fp);
261 }
262
263 /* if audio 1 interrupt */
264 if (ints & IF_AUD1) {
265 custom.intreq = IF_AUD1;
266 amiga_do_irq(IRQ_AMIGA_AUD1, fp);
267 }
268
269 /* if audio 2 interrupt */
270 if (ints & IF_AUD2) {
271 custom.intreq = IF_AUD2;
272 amiga_do_irq(IRQ_AMIGA_AUD2, fp);
273 }
274
275 /* if audio 3 interrupt */
276 if (ints & IF_AUD3) {
277 custom.intreq = IF_AUD3;
278 amiga_do_irq(IRQ_AMIGA_AUD3, fp);
279 }
280}
281
282static void ami_int5(int irq, void *dev_id, struct pt_regs *fp)
283{
284 unsigned short ints = custom.intreqr & custom.intenar;
285
286 /* if serial receive buffer full interrupt */
287 if (ints & IF_RBF) {
288 /* acknowledge of IF_RBF must be done by the serial interrupt */
289 amiga_do_irq(IRQ_AMIGA_RBF, fp);
290 }
291
292 /* if a disk sync interrupt */
293 if (ints & IF_DSKSYN) {
294 custom.intreq = IF_DSKSYN;
295 amiga_do_irq(IRQ_AMIGA_DSKSYN, fp);
296 }
297}
298
299static void ami_int7(int irq, void *dev_id, struct pt_regs *fp)
300{
301 panic ("level 7 interrupt received\n");
302}
303
304#ifdef CONFIG_APUS
305/* The PPC irq handling links all handlers requested on the same vector
306 and executes them in a loop. Having ami_badint at the end of the chain
307 is a bad idea. */
308struct irqaction amiga_sys_irqaction[AUTO_IRQS] = {
309 { .handler = ami_badint, .name = "spurious int" },
310 { .handler = ami_int1, .name = "int1 handler" },
311 { 0, /* CIAA */ },
312 { .handler = ami_int3, .name = "int3 handler" },
313 { .handler = ami_int4, .name = "int4 handler" },
314 { .handler = ami_int5, .name = "int5 handler" },
315 { 0, /* CIAB */ },
316 { .handler = ami_int7, .name = "int7 handler" },
317};
318#else
319void (*amiga_default_handler[SYS_IRQS])(int, void *, struct pt_regs *) = {
320 ami_badint, ami_int1, ami_badint, ami_int3,
321 ami_int4, ami_int5, ami_badint, ami_int7
322};
323#endif
diff --git a/arch/ppc/amiga/amisound.c b/arch/ppc/amiga/amisound.c
new file mode 100644
index 000000000000..2b86cbef79f6
--- /dev/null
+++ b/arch/ppc/amiga/amisound.c
@@ -0,0 +1 @@
#include "../../m68k/amiga/amisound.c"
diff --git a/arch/ppc/amiga/bootinfo.c b/arch/ppc/amiga/bootinfo.c
new file mode 100644
index 000000000000..e2e965661d03
--- /dev/null
+++ b/arch/ppc/amiga/bootinfo.c
@@ -0,0 +1,80 @@
1/*
2 * arch/ppc/amiga/bootinfo.c
3 *
4 * Extracted from arch/m68k/kernel/setup.c.
5 * Should be properly generalized and put somewhere else.
6 * Jesper
7 */
8
9#include <linux/types.h>
10#include <linux/kernel.h>
11#include <linux/string.h>
12#include <linux/init.h>
13
14#include <asm/setup.h>
15#include <asm/bootinfo.h>
16
17extern char cmd_line[CL_SIZE];
18
19extern int num_memory;
20extern int m68k_realnum_memory;
21extern struct mem_info memory[NUM_MEMINFO];
22extern struct mem_info m68k_memory[NUM_MEMINFO];
23extern struct mem_info ramdisk;
24
25extern int amiga_parse_bootinfo(const struct bi_record *);
26extern int atari_parse_bootinfo(const struct bi_record *);
27extern int mac_parse_bootinfo(const struct bi_record *);
28
29void __init parse_bootinfo(const struct bi_record *record)
30{
31 while (record->tag != BI_LAST) {
32 int unknown = 0;
33 const u_long *data = record->data;
34 switch (record->tag) {
35 case BI_MACHTYPE:
36 case BI_CPUTYPE:
37 case BI_FPUTYPE:
38 case BI_MMUTYPE:
39 /* Already set up by head.S */
40 break;
41
42 case BI_MEMCHUNK:
43 if (num_memory < NUM_MEMINFO) {
44 memory[num_memory].addr = data[0];
45 memory[num_memory].size = data[1];
46 num_memory++;
47
48 /* FIXME: duplicate for m68k drivers. */
49 m68k_memory[m68k_realnum_memory].addr = data[0];
50 m68k_memory[m68k_realnum_memory].size = data[1];
51 m68k_realnum_memory++;
52 } else
53 printk("parse_bootinfo: too many memory chunks\n");
54 break;
55
56 case BI_RAMDISK:
57 ramdisk.addr = data[0];
58 ramdisk.size = data[1];
59 break;
60
61 case BI_COMMAND_LINE:
62 strlcpy(cmd_line, (const char *)data, sizeof(cmd_line));
63 break;
64
65 default:
66 if (MACH_IS_AMIGA)
67 unknown = amiga_parse_bootinfo(record);
68 else if (MACH_IS_ATARI)
69 unknown = atari_parse_bootinfo(record);
70 else if (MACH_IS_MAC)
71 unknown = mac_parse_bootinfo(record);
72 else
73 unknown = 1;
74 }
75 if (unknown)
76 printk("parse_bootinfo: unknown tag 0x%04x ignored\n",
77 record->tag);
78 record = (struct bi_record *)((u_long)record+record->size);
79 }
80}
diff --git a/arch/ppc/amiga/chipram.c b/arch/ppc/amiga/chipram.c
new file mode 100644
index 000000000000..e6ab3c6b223c
--- /dev/null
+++ b/arch/ppc/amiga/chipram.c
@@ -0,0 +1 @@
#include "../../m68k/amiga/chipram.c"
diff --git a/arch/ppc/amiga/cia.c b/arch/ppc/amiga/cia.c
new file mode 100644
index 000000000000..ad961465b6cb
--- /dev/null
+++ b/arch/ppc/amiga/cia.c
@@ -0,0 +1,178 @@
1/*
2 * arch/ppc/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/interrupt.h>
17#include <linux/irq.h>
18#include <linux/kernel_stat.h>
19#include <linux/init.h>
20
21#include <asm/irq.h>
22#include <asm/amigahw.h>
23#include <asm/amigaints.h>
24
25struct ciabase {
26 volatile struct CIA *cia;
27 u_char icr_mask, icr_data;
28 u_short int_mask;
29 int handler_irq, cia_irq, server_irq;
30 char *name;
31} ciaa_base = {
32 &ciaa, 0, 0, IF_PORTS,
33 IRQ_AMIGA_AUTO_2, IRQ_AMIGA_CIAA,
34 IRQ_AMIGA_PORTS,
35 "CIAA handler"
36}, ciab_base = {
37 &ciab, 0, 0, IF_EXTER,
38 IRQ_AMIGA_AUTO_6, IRQ_AMIGA_CIAB,
39 IRQ_AMIGA_EXTER,
40 "CIAB handler"
41};
42
43#define CIA_SET_BASE_ADJUST_IRQ(base, irq) \
44do { \
45 if (irq >= IRQ_AMIGA_CIAB) { \
46 base = &ciab_base; \
47 irq -= IRQ_AMIGA_CIAB; \
48 } else { \
49 base = &ciaa_base; \
50 irq -= IRQ_AMIGA_CIAA; \
51 } \
52} while (0)
53
54/*
55 * Cause or clear CIA interrupts, return old interrupt status.
56 */
57
58static unsigned char cia_set_irq_private(struct ciabase *base,
59 unsigned char mask)
60{
61 u_char old;
62
63 old = (base->icr_data |= base->cia->icr);
64 if (mask & CIA_ICR_SETCLR)
65 base->icr_data |= mask;
66 else
67 base->icr_data &= ~mask;
68 if (base->icr_data & base->icr_mask)
69 custom.intreq = IF_SETCLR | base->int_mask;
70 return old & base->icr_mask;
71}
72
73unsigned char cia_set_irq(unsigned int irq, int set)
74{
75 struct ciabase *base;
76 unsigned char mask;
77
78 if (irq >= IRQ_AMIGA_CIAB)
79 mask = (1 << (irq - IRQ_AMIGA_CIAB));
80 else
81 mask = (1 << (irq - IRQ_AMIGA_CIAA));
82 mask |= (set) ? CIA_ICR_SETCLR : 0;
83
84 CIA_SET_BASE_ADJUST_IRQ(base, irq);
85
86 return cia_set_irq_private(base, mask);
87}
88
89unsigned char cia_get_irq_mask(unsigned int irq)
90{
91 struct ciabase *base;
92
93 CIA_SET_BASE_ADJUST_IRQ(base, irq);
94
95 return base->cia->icr;
96}
97
98/*
99 * Enable or disable CIA interrupts, return old interrupt mask.
100 */
101
102static unsigned char cia_able_irq_private(struct ciabase *base,
103 unsigned char mask)
104{
105 u_char old;
106
107 old = base->icr_mask;
108 base->icr_data |= base->cia->icr;
109 base->cia->icr = mask;
110 if (mask & CIA_ICR_SETCLR)
111 base->icr_mask |= mask;
112 else
113 base->icr_mask &= ~mask;
114 base->icr_mask &= CIA_ICR_ALL;
115
116 if (base->icr_data & base->icr_mask)
117 custom.intreq = IF_SETCLR | base->int_mask;
118 return old;
119}
120
121unsigned char cia_able_irq(unsigned int irq, int enable)
122{
123 struct ciabase *base;
124 unsigned char mask;
125
126 if (irq >= IRQ_AMIGA_CIAB)
127 mask = (1 << (irq - IRQ_AMIGA_CIAB));
128 else
129 mask = (1 << (irq - IRQ_AMIGA_CIAA));
130 mask |= (enable) ? CIA_ICR_SETCLR : 0;
131
132 CIA_SET_BASE_ADJUST_IRQ(base, irq);
133
134 return cia_able_irq_private(base, mask);
135}
136
137static void cia_handler(int irq, void *dev_id, struct pt_regs *fp)
138{
139 struct ciabase *base = (struct ciabase *)dev_id;
140 irq_desc_t *desc;
141 struct irqaction *action;
142 int i;
143 unsigned char ints;
144
145 irq = base->cia_irq;
146 desc = irq_desc + irq;
147 ints = cia_set_irq_private(base, CIA_ICR_ALL);
148 custom.intreq = base->int_mask;
149 for (i = 0; i < CIA_IRQS; i++, irq++) {
150 if (ints & 1) {
151 kstat_cpu(0).irqs[irq]++;
152 action = desc->action;
153 action->handler(irq, action->dev_id, fp);
154 }
155 ints >>= 1;
156 desc++;
157 }
158 amiga_do_irq_list(base->server_irq, fp);
159}
160
161void __init cia_init_IRQ(struct ciabase *base)
162{
163 extern struct irqaction amiga_sys_irqaction[AUTO_IRQS];
164 struct irqaction *action;
165
166 /* clear any pending interrupt and turn off all interrupts */
167 cia_set_irq_private(base, CIA_ICR_ALL);
168 cia_able_irq_private(base, CIA_ICR_ALL);
169
170 /* install CIA handler */
171 action = &amiga_sys_irqaction[base->handler_irq-IRQ_AMIGA_AUTO];
172 action->handler = cia_handler;
173 action->dev_id = base;
174 action->name = base->name;
175 setup_irq(base->handler_irq, &amiga_sys_irqaction[base->handler_irq-IRQ_AMIGA_AUTO]);
176
177 custom.intena = IF_SETCLR | base->int_mask;
178}
diff --git a/arch/ppc/amiga/config.c b/arch/ppc/amiga/config.c
new file mode 100644
index 000000000000..af881d7454dd
--- /dev/null
+++ b/arch/ppc/amiga/config.c
@@ -0,0 +1,962 @@
1#define m68k_debug_device debug_device
2
3/*
4 * arch/ppc/amiga/config.c
5 *
6 * Copyright (C) 1993 Hamish Macdonald
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/*
14 * Miscellaneous Amiga stuff
15 */
16
17#include <linux/config.h>
18#include <linux/types.h>
19#include <linux/kernel.h>
20#include <linux/mm.h>
21#include <linux/kd.h>
22#include <linux/tty.h>
23#include <linux/console.h>
24#include <linux/init.h>
25#ifdef CONFIG_ZORRO
26#include <linux/zorro.h>
27#endif
28
29#include <asm/bootinfo.h>
30#include <asm/setup.h>
31#include <asm/system.h>
32#include <asm/pgtable.h>
33#include <asm/amigahw.h>
34#include <asm/amigaints.h>
35#include <asm/irq.h>
36#include <asm/machdep.h>
37#include <asm/io.h>
38
39unsigned long powerup_PCI_present;
40unsigned long powerup_BPPCPLUS_present;
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 s_a500, s_a500p, s_a600, s_a1000, s_a1200, s_a2000, s_a2500, s_a3000,
67 s_a3000t, s_a3000p, s_a4000, s_a4000t, s_cdtv, s_cd32, s_draco,
68};
69
70static char amiga_model_name[13] = "Amiga ";
71
72extern char m68k_debug_device[];
73
74static void amiga_sched_init(irqreturn_t (*handler)(int, void *, struct pt_regs *));
75/* amiga specific irq functions */
76extern void amiga_init_IRQ (void);
77extern void (*amiga_default_handler[]) (int, void *, struct pt_regs *);
78extern int amiga_request_irq (unsigned int irq,
79 void (*handler)(int, void *, struct pt_regs *),
80 unsigned long flags, const char *devname,
81 void *dev_id);
82extern void amiga_free_irq (unsigned int irq, void *dev_id);
83extern void amiga_enable_irq (unsigned int);
84extern void amiga_disable_irq (unsigned int);
85static void amiga_get_model(char *model);
86static int amiga_get_hardware_list(char *buffer);
87/* amiga specific timer functions */
88static unsigned long amiga_gettimeoffset (void);
89static void a3000_gettod (int *, int *, int *, int *, int *, int *);
90static void a2000_gettod (int *, int *, int *, int *, int *, int *);
91static int amiga_hwclk (int, struct hwclk_time *);
92static int amiga_set_clock_mmss (unsigned long);
93#ifdef CONFIG_AMIGA_FLOPPY
94extern void amiga_floppy_setup(char *, int *);
95#endif
96static void amiga_reset (void);
97extern void amiga_init_sound(void);
98static void amiga_savekmsg_init(void);
99static void amiga_mem_console_write(struct console *co, const char *b,
100 unsigned int count);
101void amiga_serial_console_write(struct console *co, const char *s,
102 unsigned int count);
103static void amiga_debug_init(void);
104#ifdef CONFIG_HEARTBEAT
105static void amiga_heartbeat(int on);
106#endif
107
108static struct console amiga_console_driver = {
109 .name = "debug",
110 .flags = CON_PRINTBUFFER,
111 .index = -1,
112};
113
114
115 /*
116 * Motherboard Resources present in all Amiga models
117 */
118
119static struct {
120 struct resource _ciab, _ciaa, _custom, _kickstart;
121} mb_resources = {
122// { "Ranger Memory", 0x00c00000, 0x00c7ffff },
123 ._ciab = { "CIA B", 0x00bfd000, 0x00bfdfff },
124 ._ciaa = { "CIA A", 0x00bfe000, 0x00bfefff },
125 ._custom = { "Custom I/O", 0x00dff000, 0x00dfffff },
126 ._kickstart = { "Kickstart ROM", 0x00f80000, 0x00ffffff }
127};
128
129static struct resource rtc_resource = {
130 NULL, 0x00dc0000, 0x00dcffff
131};
132
133static struct resource ram_resource[NUM_MEMINFO];
134
135
136 /*
137 * Parse an Amiga-specific record in the bootinfo
138 */
139
140int amiga_parse_bootinfo(const struct bi_record *record)
141{
142 int unknown = 0;
143 const unsigned long *data = record->data;
144
145 switch (record->tag) {
146 case BI_AMIGA_MODEL:
147 {
148 unsigned long d = *data;
149
150 powerup_PCI_present = d & 0x100;
151 amiga_model = d & 0xff;
152 }
153 break;
154
155 case BI_AMIGA_ECLOCK:
156 amiga_eclock = *data;
157 break;
158
159 case BI_AMIGA_CHIPSET:
160 amiga_chipset = *data;
161 break;
162
163 case BI_AMIGA_CHIP_SIZE:
164 amiga_chip_size = *(const int *)data;
165 break;
166
167 case BI_AMIGA_VBLANK:
168 amiga_vblank = *(const unsigned char *)data;
169 break;
170
171 case BI_AMIGA_PSFREQ:
172 amiga_psfreq = *(const unsigned char *)data;
173 break;
174
175 case BI_AMIGA_AUTOCON:
176#ifdef CONFIG_ZORRO
177 if (zorro_num_autocon < ZORRO_NUM_AUTO) {
178 const struct ConfigDev *cd = (struct ConfigDev *)data;
179 struct zorro_dev *dev = &zorro_autocon[zorro_num_autocon++];
180 dev->rom = cd->cd_Rom;
181 dev->slotaddr = cd->cd_SlotAddr;
182 dev->slotsize = cd->cd_SlotSize;
183 dev->resource.start = (unsigned long)cd->cd_BoardAddr;
184 dev->resource.end = dev->resource.start+cd->cd_BoardSize-1;
185 } else
186 printk("amiga_parse_bootinfo: too many AutoConfig devices\n");
187#endif /* CONFIG_ZORRO */
188 break;
189
190 case BI_AMIGA_SERPER:
191 /* serial port period: ignored here */
192 break;
193
194 case BI_AMIGA_PUP_BRIDGE:
195 powerup_PCI_present = *(const unsigned short *)data;
196 break;
197
198 case BI_AMIGA_BPPC_SCSI:
199 powerup_BPPCPLUS_present = *(const unsigned short *)data;
200 break;
201
202 default:
203 unknown = 1;
204 }
205 return(unknown);
206}
207
208 /*
209 * Identify builtin hardware
210 */
211
212static void __init amiga_identify(void)
213{
214 /* Fill in some default values, if necessary */
215 if (amiga_eclock == 0)
216 amiga_eclock = 709379;
217
218 memset(&amiga_hw_present, 0, sizeof(amiga_hw_present));
219
220 printk("Amiga hardware found: ");
221 if (amiga_model >= AMI_500 && amiga_model <= AMI_DRACO) {
222 printk("[%s] ", amiga_models[amiga_model-AMI_500]);
223 strcat(amiga_model_name, amiga_models[amiga_model-AMI_500]);
224 }
225
226 switch(amiga_model) {
227 case AMI_UNKNOWN:
228 goto Generic;
229
230 case AMI_600:
231 case AMI_1200:
232 AMIGAHW_SET(A1200_IDE);
233 AMIGAHW_SET(PCMCIA);
234 case AMI_500:
235 case AMI_500PLUS:
236 case AMI_1000:
237 case AMI_2000:
238 case AMI_2500:
239 AMIGAHW_SET(A2000_CLK); /* Is this correct for all models? */
240 goto Generic;
241
242 case AMI_3000:
243 case AMI_3000T:
244 AMIGAHW_SET(AMBER_FF);
245 AMIGAHW_SET(MAGIC_REKICK);
246 /* fall through */
247 case AMI_3000PLUS:
248 AMIGAHW_SET(A3000_SCSI);
249 AMIGAHW_SET(A3000_CLK);
250 AMIGAHW_SET(ZORRO3);
251 goto Generic;
252
253 case AMI_4000T:
254 AMIGAHW_SET(A4000_SCSI);
255 /* fall through */
256 case AMI_4000:
257 AMIGAHW_SET(A4000_IDE);
258 AMIGAHW_SET(A3000_CLK);
259 AMIGAHW_SET(ZORRO3);
260 goto Generic;
261
262 case AMI_CDTV:
263 case AMI_CD32:
264 AMIGAHW_SET(CD_ROM);
265 AMIGAHW_SET(A2000_CLK); /* Is this correct? */
266 goto Generic;
267
268 Generic:
269 AMIGAHW_SET(AMI_VIDEO);
270 AMIGAHW_SET(AMI_BLITTER);
271 AMIGAHW_SET(AMI_AUDIO);
272 AMIGAHW_SET(AMI_FLOPPY);
273 AMIGAHW_SET(AMI_KEYBOARD);
274 AMIGAHW_SET(AMI_MOUSE);
275 AMIGAHW_SET(AMI_SERIAL);
276 AMIGAHW_SET(AMI_PARALLEL);
277 AMIGAHW_SET(CHIP_RAM);
278 AMIGAHW_SET(PAULA);
279
280 switch(amiga_chipset) {
281 case CS_OCS:
282 case CS_ECS:
283 case CS_AGA:
284 switch (custom.deniseid & 0xf) {
285 case 0x0c:
286 AMIGAHW_SET(DENISE_HR);
287 break;
288 case 0x08:
289 AMIGAHW_SET(LISA);
290 break;
291 }
292 break;
293 default:
294 AMIGAHW_SET(DENISE);
295 break;
296 }
297 switch ((custom.vposr>>8) & 0x7f) {
298 case 0x00:
299 AMIGAHW_SET(AGNUS_PAL);
300 break;
301 case 0x10:
302 AMIGAHW_SET(AGNUS_NTSC);
303 break;
304 case 0x20:
305 case 0x21:
306 AMIGAHW_SET(AGNUS_HR_PAL);
307 break;
308 case 0x30:
309 case 0x31:
310 AMIGAHW_SET(AGNUS_HR_NTSC);
311 break;
312 case 0x22:
313 case 0x23:
314 AMIGAHW_SET(ALICE_PAL);
315 break;
316 case 0x32:
317 case 0x33:
318 AMIGAHW_SET(ALICE_NTSC);
319 break;
320 }
321 AMIGAHW_SET(ZORRO);
322 break;
323
324 case AMI_DRACO:
325 panic("No support for Draco yet");
326
327 default:
328 panic("Unknown Amiga Model");
329 }
330
331#define AMIGAHW_ANNOUNCE(name, str) \
332 if (AMIGAHW_PRESENT(name)) \
333 printk(str)
334
335 AMIGAHW_ANNOUNCE(AMI_VIDEO, "VIDEO ");
336 AMIGAHW_ANNOUNCE(AMI_BLITTER, "BLITTER ");
337 AMIGAHW_ANNOUNCE(AMBER_FF, "AMBER_FF ");
338 AMIGAHW_ANNOUNCE(AMI_AUDIO, "AUDIO ");
339 AMIGAHW_ANNOUNCE(AMI_FLOPPY, "FLOPPY ");
340 AMIGAHW_ANNOUNCE(A3000_SCSI, "A3000_SCSI ");
341 AMIGAHW_ANNOUNCE(A4000_SCSI, "A4000_SCSI ");
342 AMIGAHW_ANNOUNCE(A1200_IDE, "A1200_IDE ");
343 AMIGAHW_ANNOUNCE(A4000_IDE, "A4000_IDE ");
344 AMIGAHW_ANNOUNCE(CD_ROM, "CD_ROM ");
345 AMIGAHW_ANNOUNCE(AMI_KEYBOARD, "KEYBOARD ");
346 AMIGAHW_ANNOUNCE(AMI_MOUSE, "MOUSE ");
347 AMIGAHW_ANNOUNCE(AMI_SERIAL, "SERIAL ");
348 AMIGAHW_ANNOUNCE(AMI_PARALLEL, "PARALLEL ");
349 AMIGAHW_ANNOUNCE(A2000_CLK, "A2000_CLK ");
350 AMIGAHW_ANNOUNCE(A3000_CLK, "A3000_CLK ");
351 AMIGAHW_ANNOUNCE(CHIP_RAM, "CHIP_RAM ");
352 AMIGAHW_ANNOUNCE(PAULA, "PAULA ");
353 AMIGAHW_ANNOUNCE(DENISE, "DENISE ");
354 AMIGAHW_ANNOUNCE(DENISE_HR, "DENISE_HR ");
355 AMIGAHW_ANNOUNCE(LISA, "LISA ");
356 AMIGAHW_ANNOUNCE(AGNUS_PAL, "AGNUS_PAL ");
357 AMIGAHW_ANNOUNCE(AGNUS_NTSC, "AGNUS_NTSC ");
358 AMIGAHW_ANNOUNCE(AGNUS_HR_PAL, "AGNUS_HR_PAL ");
359 AMIGAHW_ANNOUNCE(AGNUS_HR_NTSC, "AGNUS_HR_NTSC ");
360 AMIGAHW_ANNOUNCE(ALICE_PAL, "ALICE_PAL ");
361 AMIGAHW_ANNOUNCE(ALICE_NTSC, "ALICE_NTSC ");
362 AMIGAHW_ANNOUNCE(MAGIC_REKICK, "MAGIC_REKICK ");
363 AMIGAHW_ANNOUNCE(PCMCIA, "PCMCIA ");
364 if (AMIGAHW_PRESENT(ZORRO))
365 printk("ZORRO%s ", AMIGAHW_PRESENT(ZORRO3) ? "3" : "");
366 printk("\n");
367
368#undef AMIGAHW_ANNOUNCE
369}
370
371 /*
372 * Setup the Amiga configuration info
373 */
374
375void __init config_amiga(void)
376{
377 int i;
378
379 amiga_debug_init();
380 amiga_identify();
381
382 /* Some APUS boxes may have PCI memory, but ... */
383 iomem_resource.name = "Memory";
384 for (i = 0; i < 4; i++)
385 request_resource(&iomem_resource, &((struct resource *)&mb_resources)[i]);
386
387 mach_sched_init = amiga_sched_init;
388 mach_init_IRQ = amiga_init_IRQ;
389#ifndef CONFIG_APUS
390 mach_default_handler = &amiga_default_handler;
391 mach_request_irq = amiga_request_irq;
392 mach_free_irq = amiga_free_irq;
393 enable_irq = amiga_enable_irq;
394 disable_irq = amiga_disable_irq;
395#endif
396 mach_get_model = amiga_get_model;
397 mach_get_hardware_list = amiga_get_hardware_list;
398 mach_gettimeoffset = amiga_gettimeoffset;
399 if (AMIGAHW_PRESENT(A3000_CLK)){
400 mach_gettod = a3000_gettod;
401 rtc_resource.name = "A3000 RTC";
402 request_resource(&iomem_resource, &rtc_resource);
403 }
404 else{ /* if (AMIGAHW_PRESENT(A2000_CLK)) */
405 mach_gettod = a2000_gettod;
406 rtc_resource.name = "A2000 RTC";
407 request_resource(&iomem_resource, &rtc_resource);
408 }
409
410 mach_max_dma_address = 0xffffffff; /*
411 * default MAX_DMA=0xffffffff
412 * on all machines. If we don't
413 * do so, the SCSI code will not
414 * be able to allocate any mem
415 * for transfers, unless we are
416 * dealing with a Z2 mem only
417 * system. /Jes
418 */
419
420 mach_hwclk = amiga_hwclk;
421 mach_set_clock_mmss = amiga_set_clock_mmss;
422#ifdef CONFIG_AMIGA_FLOPPY
423 mach_floppy_setup = amiga_floppy_setup;
424#endif
425 mach_reset = amiga_reset;
426#ifdef CONFIG_HEARTBEAT
427 mach_heartbeat = amiga_heartbeat;
428#endif
429
430 /* Fill in the clock values (based on the 700 kHz E-Clock) */
431 amiga_masterclock = 40*amiga_eclock; /* 28 MHz */
432 amiga_colorclock = 5*amiga_eclock; /* 3.5 MHz */
433
434 /* clear all DMA bits */
435 custom.dmacon = DMAF_ALL;
436 /* ensure that the DMA master bit is set */
437 custom.dmacon = DMAF_SETCLR | DMAF_MASTER;
438
439 /* request all RAM */
440 for (i = 0; i < m68k_num_memory; i++) {
441 ram_resource[i].name =
442 (m68k_memory[i].addr >= 0x01000000) ? "32-bit Fast RAM" :
443 (m68k_memory[i].addr < 0x00c00000) ? "16-bit Fast RAM" :
444 "16-bit Slow RAM";
445 ram_resource[i].start = m68k_memory[i].addr;
446 ram_resource[i].end = m68k_memory[i].addr+m68k_memory[i].size-1;
447 request_resource(&iomem_resource, &ram_resource[i]);
448 }
449
450 /* initialize chipram allocator */
451 amiga_chip_init ();
452
453 /* debugging using chipram */
454 if (!strcmp( m68k_debug_device, "mem" )){
455 if (!AMIGAHW_PRESENT(CHIP_RAM))
456 printk("Warning: no chipram present for debugging\n");
457 else {
458 amiga_savekmsg_init();
459 amiga_console_driver.write = amiga_mem_console_write;
460 register_console(&amiga_console_driver);
461 }
462 }
463
464 /* our beloved beeper */
465 if (AMIGAHW_PRESENT(AMI_AUDIO))
466 amiga_init_sound();
467
468 /*
469 * if it is an A3000, set the magic bit that forces
470 * a hard rekick
471 */
472 if (AMIGAHW_PRESENT(MAGIC_REKICK))
473 *(unsigned char *)ZTWO_VADDR(0xde0002) |= 0x80;
474}
475
476static unsigned short jiffy_ticks;
477
478static void __init amiga_sched_init(irqreturn_t (*timer_routine)(int, void *,
479 struct pt_regs *))
480{
481 static struct resource sched_res = {
482 "timer", 0x00bfd400, 0x00bfd5ff,
483 };
484 jiffy_ticks = (amiga_eclock+HZ/2)/HZ;
485
486 if (request_resource(&mb_resources._ciab, &sched_res))
487 printk("Cannot allocate ciab.ta{lo,hi}\n");
488 ciab.cra &= 0xC0; /* turn off timer A, continuous mode, from Eclk */
489 ciab.talo = jiffy_ticks % 256;
490 ciab.tahi = jiffy_ticks / 256;
491
492 /* install interrupt service routine for CIAB Timer A
493 *
494 * Please don't change this to use ciaa, as it interferes with the
495 * SCSI code. We'll have to take a look at this later
496 */
497 request_irq(IRQ_AMIGA_CIAB_TA, timer_routine, 0, "timer", NULL);
498 /* start timer */
499 ciab.cra |= 0x11;
500}
501
502#define TICK_SIZE 10000
503
504extern unsigned char cia_get_irq_mask(unsigned int irq);
505
506/* This is always executed with interrupts disabled. */
507static unsigned long amiga_gettimeoffset (void)
508{
509 unsigned short hi, lo, hi2;
510 unsigned long ticks, offset = 0;
511
512 /* read CIA B timer A current value */
513 hi = ciab.tahi;
514 lo = ciab.talo;
515 hi2 = ciab.tahi;
516
517 if (hi != hi2) {
518 lo = ciab.talo;
519 hi = hi2;
520 }
521
522 ticks = hi << 8 | lo;
523
524 if (ticks > jiffy_ticks / 2)
525 /* check for pending interrupt */
526 if (cia_get_irq_mask(IRQ_AMIGA_CIAB) & CIA_ICR_TA)
527 offset = 10000;
528
529 ticks = jiffy_ticks - ticks;
530 ticks = (10000 * ticks) / jiffy_ticks;
531
532 return ticks + offset;
533}
534
535static void a3000_gettod (int *yearp, int *monp, int *dayp,
536 int *hourp, int *minp, int *secp)
537{
538 volatile struct tod3000 *tod = TOD_3000;
539
540 tod->cntrl1 = TOD3000_CNTRL1_HOLD;
541
542 *secp = tod->second1 * 10 + tod->second2;
543 *minp = tod->minute1 * 10 + tod->minute2;
544 *hourp = tod->hour1 * 10 + tod->hour2;
545 *dayp = tod->day1 * 10 + tod->day2;
546 *monp = tod->month1 * 10 + tod->month2;
547 *yearp = tod->year1 * 10 + tod->year2;
548
549 tod->cntrl1 = TOD3000_CNTRL1_FREE;
550}
551
552static void a2000_gettod (int *yearp, int *monp, int *dayp,
553 int *hourp, int *minp, int *secp)
554{
555 volatile struct tod2000 *tod = TOD_2000;
556
557 tod->cntrl1 = TOD2000_CNTRL1_HOLD;
558
559 while (tod->cntrl1 & TOD2000_CNTRL1_BUSY)
560 ;
561
562 *secp = tod->second1 * 10 + tod->second2;
563 *minp = tod->minute1 * 10 + tod->minute2;
564 *hourp = (tod->hour1 & 3) * 10 + tod->hour2;
565 *dayp = tod->day1 * 10 + tod->day2;
566 *monp = tod->month1 * 10 + tod->month2;
567 *yearp = tod->year1 * 10 + tod->year2;
568
569 if (!(tod->cntrl3 & TOD2000_CNTRL3_24HMODE)){
570 if (!(tod->hour1 & TOD2000_HOUR1_PM) && *hourp == 12)
571 *hourp = 0;
572 else if ((tod->hour1 & TOD2000_HOUR1_PM) && *hourp != 12)
573 *hourp += 12;
574 }
575
576 tod->cntrl1 &= ~TOD2000_CNTRL1_HOLD;
577}
578
579static int amiga_hwclk(int op, struct hwclk_time *t)
580{
581 if (AMIGAHW_PRESENT(A3000_CLK)) {
582 volatile struct tod3000 *tod = TOD_3000;
583
584 tod->cntrl1 = TOD3000_CNTRL1_HOLD;
585
586 if (!op) { /* read */
587 t->sec = tod->second1 * 10 + tod->second2;
588 t->min = tod->minute1 * 10 + tod->minute2;
589 t->hour = tod->hour1 * 10 + tod->hour2;
590 t->day = tod->day1 * 10 + tod->day2;
591 t->wday = tod->weekday;
592 t->mon = tod->month1 * 10 + tod->month2 - 1;
593 t->year = tod->year1 * 10 + tod->year2;
594 if (t->year <= 69)
595 t->year += 100;
596 } else {
597 tod->second1 = t->sec / 10;
598 tod->second2 = t->sec % 10;
599 tod->minute1 = t->min / 10;
600 tod->minute2 = t->min % 10;
601 tod->hour1 = t->hour / 10;
602 tod->hour2 = t->hour % 10;
603 tod->day1 = t->day / 10;
604 tod->day2 = t->day % 10;
605 if (t->wday != -1)
606 tod->weekday = t->wday;
607 tod->month1 = (t->mon + 1) / 10;
608 tod->month2 = (t->mon + 1) % 10;
609 if (t->year >= 100)
610 t->year -= 100;
611 tod->year1 = t->year / 10;
612 tod->year2 = t->year % 10;
613 }
614
615 tod->cntrl1 = TOD3000_CNTRL1_FREE;
616 } else /* if (AMIGAHW_PRESENT(A2000_CLK)) */ {
617 volatile struct tod2000 *tod = TOD_2000;
618
619 tod->cntrl1 = TOD2000_CNTRL1_HOLD;
620
621 while (tod->cntrl1 & TOD2000_CNTRL1_BUSY)
622 ;
623
624 if (!op) { /* read */
625 t->sec = tod->second1 * 10 + tod->second2;
626 t->min = tod->minute1 * 10 + tod->minute2;
627 t->hour = (tod->hour1 & 3) * 10 + tod->hour2;
628 t->day = tod->day1 * 10 + tod->day2;
629 t->wday = tod->weekday;
630 t->mon = tod->month1 * 10 + tod->month2 - 1;
631 t->year = tod->year1 * 10 + tod->year2;
632 if (t->year <= 69)
633 t->year += 100;
634
635 if (!(tod->cntrl3 & TOD2000_CNTRL3_24HMODE)){
636 if (!(tod->hour1 & TOD2000_HOUR1_PM) && t->hour == 12)
637 t->hour = 0;
638 else if ((tod->hour1 & TOD2000_HOUR1_PM) && t->hour != 12)
639 t->hour += 12;
640 }
641 } else {
642 tod->second1 = t->sec / 10;
643 tod->second2 = t->sec % 10;
644 tod->minute1 = t->min / 10;
645 tod->minute2 = t->min % 10;
646 if (tod->cntrl3 & TOD2000_CNTRL3_24HMODE)
647 tod->hour1 = t->hour / 10;
648 else if (t->hour >= 12)
649 tod->hour1 = TOD2000_HOUR1_PM +
650 (t->hour - 12) / 10;
651 else
652 tod->hour1 = t->hour / 10;
653 tod->hour2 = t->hour % 10;
654 tod->day1 = t->day / 10;
655 tod->day2 = t->day % 10;
656 if (t->wday != -1)
657 tod->weekday = t->wday;
658 tod->month1 = (t->mon + 1) / 10;
659 tod->month2 = (t->mon + 1) % 10;
660 if (t->year >= 100)
661 t->year -= 100;
662 tod->year1 = t->year / 10;
663 tod->year2 = t->year % 10;
664 }
665
666 tod->cntrl1 &= ~TOD2000_CNTRL1_HOLD;
667 }
668
669 return 0;
670}
671
672static int amiga_set_clock_mmss (unsigned long nowtime)
673{
674 short real_seconds = nowtime % 60, real_minutes = (nowtime / 60) % 60;
675
676 if (AMIGAHW_PRESENT(A3000_CLK)) {
677 volatile struct tod3000 *tod = TOD_3000;
678
679 tod->cntrl1 = TOD3000_CNTRL1_HOLD;
680
681 tod->second1 = real_seconds / 10;
682 tod->second2 = real_seconds % 10;
683 tod->minute1 = real_minutes / 10;
684 tod->minute2 = real_minutes % 10;
685
686 tod->cntrl1 = TOD3000_CNTRL1_FREE;
687 } else /* if (AMIGAHW_PRESENT(A2000_CLK)) */ {
688 volatile struct tod2000 *tod = TOD_2000;
689
690 tod->cntrl1 = TOD2000_CNTRL1_HOLD;
691
692 while (tod->cntrl1 & TOD2000_CNTRL1_BUSY)
693 ;
694
695 tod->second1 = real_seconds / 10;
696 tod->second2 = real_seconds % 10;
697 tod->minute1 = real_minutes / 10;
698 tod->minute2 = real_minutes % 10;
699
700 tod->cntrl1 &= ~TOD2000_CNTRL1_HOLD;
701 }
702
703 return 0;
704}
705
706static NORET_TYPE void amiga_reset( void )
707 ATTRIB_NORET;
708
709static void amiga_reset (void)
710{
711 for (;;);
712}
713
714
715 /*
716 * Debugging
717 */
718
719#define SAVEKMSG_MAXMEM 128*1024
720
721#define SAVEKMSG_MAGIC1 0x53415645 /* 'SAVE' */
722#define SAVEKMSG_MAGIC2 0x4B4D5347 /* 'KMSG' */
723
724struct savekmsg {
725 unsigned long magic1; /* SAVEKMSG_MAGIC1 */
726 unsigned long magic2; /* SAVEKMSG_MAGIC2 */
727 unsigned long magicptr; /* address of magic1 */
728 unsigned long size;
729 char data[0];
730};
731
732static struct savekmsg *savekmsg = NULL;
733
734static void amiga_mem_console_write(struct console *co, const char *s,
735 unsigned int count)
736{
737 if (savekmsg->size+count <= SAVEKMSG_MAXMEM-sizeof(struct savekmsg)) {
738 memcpy(savekmsg->data+savekmsg->size, s, count);
739 savekmsg->size += count;
740 }
741}
742
743static void amiga_savekmsg_init(void)
744{
745 static struct resource debug_res = { "Debug" };
746
747 savekmsg = amiga_chip_alloc_res(SAVEKMSG_MAXMEM, &debug_res);
748 savekmsg->magic1 = SAVEKMSG_MAGIC1;
749 savekmsg->magic2 = SAVEKMSG_MAGIC2;
750 savekmsg->magicptr = virt_to_phys(savekmsg);
751 savekmsg->size = 0;
752}
753
754static void amiga_serial_putc(char c)
755{
756 custom.serdat = (unsigned char)c | 0x100;
757 mb();
758 while (!(custom.serdatr & 0x2000))
759 ;
760}
761
762void amiga_serial_console_write(struct console *co, const char *s,
763 unsigned int count)
764{
765#if 0 /* def CONFIG_KGDB */
766 /* FIXME:APUS GDB doesn't seem to like O-packages before it is
767 properly connected with the target. */
768 __gdb_output_string (s, count);
769#else
770 while (count--) {
771 if (*s == '\n')
772 amiga_serial_putc('\r');
773 amiga_serial_putc(*s++);
774 }
775#endif
776}
777
778#ifdef CONFIG_SERIAL_CONSOLE
779void amiga_serial_puts(const char *s)
780{
781 amiga_serial_console_write(NULL, s, strlen(s));
782}
783
784int amiga_serial_console_wait_key(struct console *co)
785{
786 int ch;
787
788 while (!(custom.intreqr & IF_RBF))
789 barrier();
790 ch = custom.serdatr & 0xff;
791 /* clear the interrupt, so that another character can be read */
792 custom.intreq = IF_RBF;
793 return ch;
794}
795
796void amiga_serial_gets(struct console *co, char *s, int len)
797{
798 int ch, cnt = 0;
799
800 while (1) {
801 ch = amiga_serial_console_wait_key(co);
802
803 /* Check for backspace. */
804 if (ch == 8 || ch == 127) {
805 if (cnt == 0) {
806 amiga_serial_putc('\007');
807 continue;
808 }
809 cnt--;
810 amiga_serial_puts("\010 \010");
811 continue;
812 }
813
814 /* Check for enter. */
815 if (ch == 10 || ch == 13)
816 break;
817
818 /* See if line is too long. */
819 if (cnt >= len + 1) {
820 amiga_serial_putc(7);
821 cnt--;
822 continue;
823 }
824
825 /* Store and echo character. */
826 s[cnt++] = ch;
827 amiga_serial_putc(ch);
828 }
829 /* Print enter. */
830 amiga_serial_puts("\r\n");
831 s[cnt] = 0;
832}
833#endif
834
835static void __init amiga_debug_init(void)
836{
837 if (!strcmp( m68k_debug_device, "ser" )) {
838 /* no initialization required (?) */
839 amiga_console_driver.write = amiga_serial_console_write;
840 register_console(&amiga_console_driver);
841 }
842}
843
844#ifdef CONFIG_HEARTBEAT
845static void amiga_heartbeat(int on)
846{
847 if (on)
848 ciaa.pra &= ~2;
849 else
850 ciaa.pra |= 2;
851}
852#endif
853
854 /*
855 * Amiga specific parts of /proc
856 */
857
858static void amiga_get_model(char *model)
859{
860 strcpy(model, amiga_model_name);
861}
862
863
864static int amiga_get_hardware_list(char *buffer)
865{
866 int len = 0;
867
868 if (AMIGAHW_PRESENT(CHIP_RAM))
869 len += sprintf(buffer+len, "Chip RAM:\t%ldK\n", amiga_chip_size>>10);
870 len += sprintf(buffer+len, "PS Freq:\t%dHz\nEClock Freq:\t%ldHz\n",
871 amiga_psfreq, amiga_eclock);
872 if (AMIGAHW_PRESENT(AMI_VIDEO)) {
873 char *type;
874 switch(amiga_chipset) {
875 case CS_OCS:
876 type = "OCS";
877 break;
878 case CS_ECS:
879 type = "ECS";
880 break;
881 case CS_AGA:
882 type = "AGA";
883 break;
884 default:
885 type = "Old or Unknown";
886 break;
887 }
888 len += sprintf(buffer+len, "Graphics:\t%s\n", type);
889 }
890
891#define AMIGAHW_ANNOUNCE(name, str) \
892 if (AMIGAHW_PRESENT(name)) \
893 len += sprintf (buffer+len, "\t%s\n", str)
894
895 len += sprintf (buffer + len, "Detected hardware:\n");
896
897 AMIGAHW_ANNOUNCE(AMI_VIDEO, "Amiga Video");
898 AMIGAHW_ANNOUNCE(AMI_BLITTER, "Blitter");
899 AMIGAHW_ANNOUNCE(AMBER_FF, "Amber Flicker Fixer");
900 AMIGAHW_ANNOUNCE(AMI_AUDIO, "Amiga Audio");
901 AMIGAHW_ANNOUNCE(AMI_FLOPPY, "Floppy Controller");
902 AMIGAHW_ANNOUNCE(A3000_SCSI, "SCSI Controller WD33C93 (A3000 style)");
903 AMIGAHW_ANNOUNCE(A4000_SCSI, "SCSI Controller NCR53C710 (A4000T style)");
904 AMIGAHW_ANNOUNCE(A1200_IDE, "IDE Interface (A1200 style)");
905 AMIGAHW_ANNOUNCE(A4000_IDE, "IDE Interface (A4000 style)");
906 AMIGAHW_ANNOUNCE(CD_ROM, "Internal CD ROM drive");
907 AMIGAHW_ANNOUNCE(AMI_KEYBOARD, "Keyboard");
908 AMIGAHW_ANNOUNCE(AMI_MOUSE, "Mouse Port");
909 AMIGAHW_ANNOUNCE(AMI_SERIAL, "Serial Port");
910 AMIGAHW_ANNOUNCE(AMI_PARALLEL, "Parallel Port");
911 AMIGAHW_ANNOUNCE(A2000_CLK, "Hardware Clock (A2000 style)");
912 AMIGAHW_ANNOUNCE(A3000_CLK, "Hardware Clock (A3000 style)");
913 AMIGAHW_ANNOUNCE(CHIP_RAM, "Chip RAM");
914 AMIGAHW_ANNOUNCE(PAULA, "Paula 8364");
915 AMIGAHW_ANNOUNCE(DENISE, "Denise 8362");
916 AMIGAHW_ANNOUNCE(DENISE_HR, "Denise 8373");
917 AMIGAHW_ANNOUNCE(LISA, "Lisa 8375");
918 AMIGAHW_ANNOUNCE(AGNUS_PAL, "Normal/Fat PAL Agnus 8367/8371");
919 AMIGAHW_ANNOUNCE(AGNUS_NTSC, "Normal/Fat NTSC Agnus 8361/8370");
920 AMIGAHW_ANNOUNCE(AGNUS_HR_PAL, "Fat Hires PAL Agnus 8372");
921 AMIGAHW_ANNOUNCE(AGNUS_HR_NTSC, "Fat Hires NTSC Agnus 8372");
922 AMIGAHW_ANNOUNCE(ALICE_PAL, "PAL Alice 8374");
923 AMIGAHW_ANNOUNCE(ALICE_NTSC, "NTSC Alice 8374");
924 AMIGAHW_ANNOUNCE(MAGIC_REKICK, "Magic Hard Rekick");
925 AMIGAHW_ANNOUNCE(PCMCIA, "PCMCIA Slot");
926 if (AMIGAHW_PRESENT(ZORRO))
927 len += sprintf(buffer+len, "\tZorro II%s AutoConfig: %d Expansion "
928 "Device%s\n",
929 AMIGAHW_PRESENT(ZORRO3) ? "I" : "",
930 zorro_num_autocon, zorro_num_autocon == 1 ? "" : "s");
931
932#undef AMIGAHW_ANNOUNCE
933
934 return(len);
935}
936
937#ifdef CONFIG_APUS
938int get_hardware_list(char *buffer)
939{
940 extern int get_cpuinfo(char *buffer);
941 int len = 0;
942 char model[80];
943 u_long mem;
944 int i;
945
946 if (mach_get_model)
947 mach_get_model(model);
948 else
949 strcpy(model, "Unknown PowerPC");
950
951 len += sprintf(buffer+len, "Model:\t\t%s\n", model);
952 len += get_cpuinfo(buffer+len);
953 for (mem = 0, i = 0; i < m68k_realnum_memory; i++)
954 mem += m68k_memory[i].size;
955 len += sprintf(buffer+len, "System Memory:\t%ldK\n", mem>>10);
956
957 if (mach_get_hardware_list)
958 len += mach_get_hardware_list(buffer+len);
959
960 return(len);
961}
962#endif
diff --git a/arch/ppc/amiga/ints.c b/arch/ppc/amiga/ints.c
new file mode 100644
index 000000000000..5d318e498f06
--- /dev/null
+++ b/arch/ppc/amiga/ints.c
@@ -0,0 +1,160 @@
1/*
2 * arch/ppc/amiga/ints.c
3 *
4 * Linux/m68k general interrupt handling code from arch/m68k/kernel/ints.c
5 * Needed to drive the m68k emulating IRQ hardware on the PowerUp boards.
6 */
7
8#include <linux/types.h>
9#include <linux/sched.h>
10#include <linux/kernel_stat.h>
11#include <linux/errno.h>
12#include <linux/init.h>
13#include <linux/seq_file.h>
14
15#include <asm/setup.h>
16#include <asm/system.h>
17#include <asm/irq.h>
18#include <asm/traps.h>
19#include <asm/page.h>
20#include <asm/machdep.h>
21
22/* table for system interrupt handlers */
23static irq_handler_t irq_list[SYS_IRQS];
24
25static const char *default_names[SYS_IRQS] = {
26 "spurious int", "int1 handler", "int2 handler", "int3 handler",
27 "int4 handler", "int5 handler", "int6 handler", "int7 handler"
28};
29
30/* The number of spurious interrupts */
31volatile unsigned int num_spurious;
32
33#define NUM_IRQ_NODES 100
34static irq_node_t nodes[NUM_IRQ_NODES];
35
36
37/*
38 * void init_IRQ(void)
39 *
40 * Parameters: None
41 *
42 * Returns: Nothing
43 *
44 * This function should be called during kernel startup to initialize
45 * the IRQ handling routines.
46 */
47
48__init
49void m68k_init_IRQ(void)
50{
51 int i;
52
53 for (i = 0; i < SYS_IRQS; i++) {
54 if (mach_default_handler)
55 irq_list[i].handler = (*mach_default_handler)[i];
56 irq_list[i].flags = 0;
57 irq_list[i].dev_id = NULL;
58 irq_list[i].devname = default_names[i];
59 }
60
61 for (i = 0; i < NUM_IRQ_NODES; i++)
62 nodes[i].handler = NULL;
63
64 mach_init_IRQ ();
65}
66
67irq_node_t *new_irq_node(void)
68{
69 irq_node_t *node;
70 short i;
71
72 for (node = nodes, i = NUM_IRQ_NODES-1; i >= 0; node++, i--)
73 if (!node->handler)
74 return node;
75
76 printk ("new_irq_node: out of nodes\n");
77 return NULL;
78}
79
80int sys_request_irq(unsigned int irq,
81 void (*handler)(int, void *, struct pt_regs *),
82 unsigned long flags, const char *devname, void *dev_id)
83{
84 if (irq < IRQ1 || irq > IRQ7) {
85 printk("%s: Incorrect IRQ %d from %s\n",
86 __FUNCTION__, irq, devname);
87 return -ENXIO;
88 }
89
90#if 0
91 if (!(irq_list[irq].flags & IRQ_FLG_STD)) {
92 if (irq_list[irq].flags & IRQ_FLG_LOCK) {
93 printk("%s: IRQ %d from %s is not replaceable\n",
94 __FUNCTION__, irq, irq_list[irq].devname);
95 return -EBUSY;
96 }
97 if (!(flags & IRQ_FLG_REPLACE)) {
98 printk("%s: %s can't replace IRQ %d from %s\n",
99 __FUNCTION__, devname, irq, irq_list[irq].devname);
100 return -EBUSY;
101 }
102 }
103#endif
104
105 irq_list[irq].handler = handler;
106 irq_list[irq].flags = flags;
107 irq_list[irq].dev_id = dev_id;
108 irq_list[irq].devname = devname;
109 return 0;
110}
111
112void sys_free_irq(unsigned int irq, void *dev_id)
113{
114 if (irq < IRQ1 || irq > IRQ7) {
115 printk("%s: Incorrect IRQ %d\n", __FUNCTION__, irq);
116 return;
117 }
118
119 if (irq_list[irq].dev_id != dev_id)
120 printk("%s: Removing probably wrong IRQ %d from %s\n",
121 __FUNCTION__, irq, irq_list[irq].devname);
122
123 irq_list[irq].handler = (*mach_default_handler)[irq];
124 irq_list[irq].flags = 0;
125 irq_list[irq].dev_id = NULL;
126 irq_list[irq].devname = default_names[irq];
127}
128
129asmlinkage void process_int(unsigned long vec, struct pt_regs *fp)
130{
131 if (vec >= VEC_INT1 && vec <= VEC_INT7 && !MACH_IS_BVME6000) {
132 vec -= VEC_SPUR;
133 kstat_cpu(0).irqs[vec]++;
134 irq_list[vec].handler(vec, irq_list[vec].dev_id, fp);
135 } else {
136 if (mach_process_int)
137 mach_process_int(vec, fp);
138 else
139 panic("Can't process interrupt vector %ld\n", vec);
140 return;
141 }
142}
143
144int m68k_get_irq_list(struct seq_file *p, void *v)
145{
146 int i;
147
148 /* autovector interrupts */
149 if (mach_default_handler) {
150 for (i = 0; i < SYS_IRQS; i++) {
151 seq_printf(p, "auto %2d: %10u ", i,
152 i ? kstat_cpu(0).irqs[i] : num_spurious);
153 seq_puts(p, " ");
154 seq_printf(p, "%s\n", irq_list[i].devname);
155 }
156 }
157
158 mach_get_irq_list(p, v);
159 return 0;
160}
diff --git a/arch/ppc/amiga/pcmcia.c b/arch/ppc/amiga/pcmcia.c
new file mode 100644
index 000000000000..5d29dc65093c
--- /dev/null
+++ b/arch/ppc/amiga/pcmcia.c
@@ -0,0 +1 @@
#include "../../m68k/amiga/pcmcia.c"
diff --git a/arch/ppc/amiga/time.c b/arch/ppc/amiga/time.c
new file mode 100644
index 000000000000..0073527a7036
--- /dev/null
+++ b/arch/ppc/amiga/time.c
@@ -0,0 +1,58 @@
1#include <linux/config.h> /* CONFIG_HEARTBEAT */
2#include <linux/errno.h>
3#include <linux/sched.h>
4#include <linux/kernel.h>
5#include <linux/param.h>
6#include <linux/string.h>
7#include <linux/mm.h>
8
9#include <asm/machdep.h>
10#include <asm/io.h>
11
12#include <linux/timex.h>
13
14unsigned long m68k_get_rtc_time(void)
15{
16 unsigned int year, mon, day, hour, min, sec;
17
18 extern void arch_gettod(int *year, int *mon, int *day, int *hour,
19 int *min, int *sec);
20
21 arch_gettod (&year, &mon, &day, &hour, &min, &sec);
22
23 if ((year += 1900) < 1970)
24 year += 100;
25
26 return mktime(year, mon, day, hour, min, sec);
27}
28
29int m68k_set_rtc_time(unsigned long nowtime)
30{
31 if (mach_set_clock_mmss)
32 return mach_set_clock_mmss (nowtime);
33 return -1;
34}
35
36void apus_heartbeat (void)
37{
38#ifdef CONFIG_HEARTBEAT
39 static unsigned cnt = 0, period = 0, dist = 0;
40
41 if (cnt == 0 || cnt == dist)
42 mach_heartbeat( 1 );
43 else if (cnt == 7 || cnt == dist+7)
44 mach_heartbeat( 0 );
45
46 if (++cnt > period) {
47 cnt = 0;
48 /* The hyperbolic function below modifies the heartbeat period
49 * length in dependency of the current (5min) load. It goes
50 * through the points f(0)=126, f(1)=86, f(5)=51,
51 * f(inf)->30. */
52 period = ((672<<FSHIFT)/(5*avenrun[0]+(7<<FSHIFT))) + 30;
53 dist = period / 4;
54 }
55#endif
56 /* should be made smarter */
57 ppc_md.heartbeat_count = 1;
58}