aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm26/machine
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/arm26/machine
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/arm26/machine')
-rw-r--r--arch/arm26/machine/Makefile8
-rw-r--r--arch/arm26/machine/dma.c215
-rw-r--r--arch/arm26/machine/irq.c165
-rw-r--r--arch/arm26/machine/latches.c72
4 files changed, 460 insertions, 0 deletions
diff --git a/arch/arm26/machine/Makefile b/arch/arm26/machine/Makefile
new file mode 100644
index 000000000000..86ea97cc07fc
--- /dev/null
+++ b/arch/arm26/machine/Makefile
@@ -0,0 +1,8 @@
1#
2# Makefile for the linux kernel.
3#
4
5# Object file lists.
6
7obj-y := dma.o irq.o latches.o
8
diff --git a/arch/arm26/machine/dma.c b/arch/arm26/machine/dma.c
new file mode 100644
index 000000000000..cbc7c61d5b32
--- /dev/null
+++ b/arch/arm26/machine/dma.c
@@ -0,0 +1,215 @@
1/*
2 * linux/arch/arm26/kernel/dma.c
3 *
4 * Copyright (C) 1998-1999 Dave Gilbert / Russell King
5 * Copyright (C) 2003 Ian Molton
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * DMA functions specific to Archimedes and A5000 architecture
12 */
13#include <linux/config.h>
14#include <linux/sched.h>
15#include <linux/init.h>
16
17#include <asm/dma.h>
18#include <asm/fiq.h>
19#include <asm/irq.h>
20#include <asm/io.h>
21#include <asm/hardware.h>
22#include <asm/mach-types.h>
23
24#define DPRINTK(x...) printk(KERN_DEBUG x)
25
26#if defined(CONFIG_BLK_DEV_FD1772) || defined(CONFIG_BLK_DEV_FD1772_MODULE)
27
28extern unsigned char fdc1772_dma_read, fdc1772_dma_read_end;
29extern unsigned char fdc1772_dma_write, fdc1772_dma_write_end;
30extern void fdc1772_setupdma(unsigned int count,unsigned int addr);
31
32static void arc_floppy_data_enable_dma(dmach_t channel, dma_t *dma)
33{
34 DPRINTK("arc_floppy_data_enable_dma\n");
35
36 if (dma->using_sg)
37 BUG();
38
39 switch (dma->dma_mode) {
40 case DMA_MODE_READ: { /* read */
41 unsigned long flags;
42 DPRINTK("enable_dma fdc1772 data read\n");
43 local_save_flags_cli(flags);
44 clf();
45
46 memcpy ((void *)0x1c, (void *)&fdc1772_dma_read,
47 &fdc1772_dma_read_end - &fdc1772_dma_read);
48 fdc1772_setupdma(dma->buf.length, dma->buf.__address); /* Sets data pointer up */
49 enable_fiq(FIQ_FLOPPYDATA);
50 local_irq_restore(flags);
51 }
52 break;
53
54 case DMA_MODE_WRITE: { /* write */
55 unsigned long flags;
56 DPRINTK("enable_dma fdc1772 data write\n");
57 local_save_flags_cli(flags);
58 clf();
59 memcpy ((void *)0x1c, (void *)&fdc1772_dma_write,
60 &fdc1772_dma_write_end - &fdc1772_dma_write);
61 fdc1772_setupdma(dma->buf.length, dma->buf.__address); /* Sets data pointer up */
62 enable_fiq(FIQ_FLOPPYDATA);
63
64 local_irq_restore(flags);
65 }
66 break;
67 default:
68 printk ("enable_dma: dma%d not initialised\n", channel);
69 }
70}
71
72static int arc_floppy_data_get_dma_residue(dmach_t channel, dma_t *dma)
73{
74 extern unsigned int fdc1772_bytestogo;
75
76 /* 10/1/1999 DAG - I presume its the number of bytes left? */
77 return fdc1772_bytestogo;
78}
79
80static void arc_floppy_cmdend_enable_dma(dmach_t channel, dma_t *dma)
81{
82 /* Need to build a branch at the FIQ address */
83 extern void fdc1772_comendhandler(void);
84 unsigned long flags;
85
86 DPRINTK("arc_floppy_cmdend_enable_dma\n");
87 /*printk("enable_dma fdc1772 command end FIQ\n");*/
88 save_flags(flags);
89 clf();
90
91 /* B fdc1772_comendhandler */
92 *((unsigned int *)0x1c)=0xea000000 |
93 (((unsigned int)fdc1772_comendhandler-(0x1c+8))/4);
94
95 local_irq_restore(flags);
96}
97
98static int arc_floppy_cmdend_get_dma_residue(dmach_t channel, dma_t *dma)
99{
100 /* 10/1/1999 DAG - Presume whether there is an outstanding command? */
101 extern unsigned int fdc1772_fdc_int_done;
102
103 /* Explicit! If the int done is 0 then 1 int to go */
104 return (fdc1772_fdc_int_done==0)?1:0;
105}
106
107static void arc_disable_dma(dmach_t channel, dma_t *dma)
108{
109 disable_fiq(dma->dma_irq);
110}
111
112static struct dma_ops arc_floppy_data_dma_ops = {
113 .type = "FIQDMA",
114 .enable = arc_floppy_data_enable_dma,
115 .disable = arc_disable_dma,
116 .residue = arc_floppy_data_get_dma_residue,
117};
118
119static struct dma_ops arc_floppy_cmdend_dma_ops = {
120 .type = "FIQCMD",
121 .enable = arc_floppy_cmdend_enable_dma,
122 .disable = arc_disable_dma,
123 .residue = arc_floppy_cmdend_get_dma_residue,
124};
125#endif
126
127#ifdef CONFIG_ARCH_A5K
128static struct fiq_handler fh = {
129 .name = "floppydata"
130};
131
132static int a5k_floppy_get_dma_residue(dmach_t channel, dma_t *dma)
133{
134 struct pt_regs regs;
135 get_fiq_regs(&regs);
136 return regs.ARM_r9;
137}
138
139static void a5k_floppy_enable_dma(dmach_t channel, dma_t *dma)
140{
141 struct pt_regs regs;
142 void *fiqhandler_start;
143 unsigned int fiqhandler_length;
144 extern void floppy_fiqsetup(unsigned long len, unsigned long addr,
145 unsigned long port);
146
147 if (dma->using_sg)
148 BUG();
149
150 if (dma->dma_mode == DMA_MODE_READ) {
151 extern unsigned char floppy_fiqin_start, floppy_fiqin_end;
152 fiqhandler_start = &floppy_fiqin_start;
153 fiqhandler_length = &floppy_fiqin_end - &floppy_fiqin_start;
154 } else {
155 extern unsigned char floppy_fiqout_start, floppy_fiqout_end;
156 fiqhandler_start = &floppy_fiqout_start;
157 fiqhandler_length = &floppy_fiqout_end - &floppy_fiqout_start;
158 }
159 if (claim_fiq(&fh)) {
160 printk("floppydma: couldn't claim FIQ.\n");
161 return;
162 }
163 memcpy((void *)0x1c, fiqhandler_start, fiqhandler_length);
164 regs.ARM_r9 = dma->buf.length;
165 regs.ARM_r10 = (unsigned long)dma->buf.__address;
166 regs.ARM_fp = FLOPPYDMA_BASE;
167 set_fiq_regs(&regs);
168 enable_fiq(dma->dma_irq);
169}
170
171static void a5k_floppy_disable_dma(dmach_t channel, dma_t *dma)
172{
173 disable_fiq(dma->dma_irq);
174 release_fiq(&fh);
175}
176
177static struct dma_ops a5k_floppy_dma_ops = {
178 .type = "FIQDMA",
179 .enable = a5k_floppy_enable_dma,
180 .disable = a5k_floppy_disable_dma,
181 .residue = a5k_floppy_get_dma_residue,
182};
183#endif
184
185/*
186 * This is virtual DMA - we don't need anything here
187 */
188static void sound_enable_disable_dma(dmach_t channel, dma_t *dma)
189{
190}
191
192static struct dma_ops sound_dma_ops = {
193 .type = "VIRTUAL",
194 .enable = sound_enable_disable_dma,
195 .disable = sound_enable_disable_dma,
196};
197
198void __init arch_dma_init(dma_t *dma)
199{
200#if defined(CONFIG_BLK_DEV_FD1772) || defined(CONFIG_BLK_DEV_FD1772_MODULE)
201 if (machine_is_archimedes()) {
202 dma[DMA_VIRTUAL_FLOPPY0].dma_irq = FIQ_FLOPPYDATA;
203 dma[DMA_VIRTUAL_FLOPPY0].d_ops = &arc_floppy_data_dma_ops;
204 dma[DMA_VIRTUAL_FLOPPY1].dma_irq = 1;
205 dma[DMA_VIRTUAL_FLOPPY1].d_ops = &arc_floppy_cmdend_dma_ops;
206 }
207#endif
208#ifdef CONFIG_ARCH_A5K
209 if (machine_is_a5k()) {
210 dma[DMA_VIRTUAL_FLOPPY0].dma_irq = FIQ_FLOPPYDATA;
211 dma[DMA_VIRTUAL_FLOPPY0].d_ops = &a5k_floppy_dma_ops;
212 }
213#endif
214 dma[DMA_VIRTUAL_SOUND].d_ops = &sound_dma_ops;
215}
diff --git a/arch/arm26/machine/irq.c b/arch/arm26/machine/irq.c
new file mode 100644
index 000000000000..4361863f7ed2
--- /dev/null
+++ b/arch/arm26/machine/irq.c
@@ -0,0 +1,165 @@
1/*
2 * linux/arch/arm26/mach-arc/irq.c
3 *
4 * Copyright (C) 1996 Russell King
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * Changelog:
11 * 24-09-1996 RMK Created
12 * 10-10-1996 RMK Brought up to date with arch-sa110eval
13 * 22-10-1996 RMK Changed interrupt numbers & uses new inb/outb macros
14 * 11-01-1998 RMK Added mask_and_ack_irq
15 * 22-08-1998 RMK Restructured IRQ routines
16 * 08-09-2002 IM Brought up to date for 2.5
17 * 01-06-2003 JMA Removed arc_fiq_chip
18 */
19#include <linux/config.h>
20#include <linux/init.h>
21
22#include <asm/irq.h>
23#include <asm/irqchip.h>
24#include <asm/ioc.h>
25#include <asm/io.h>
26#include <asm/system.h>
27
28extern void init_FIQ(void);
29
30#define a_clf() clf()
31#define a_stf() stf()
32
33static void arc_ack_irq_a(unsigned int irq)
34{
35 unsigned int val, mask;
36
37 mask = 1 << irq;
38 a_clf();
39 val = ioc_readb(IOC_IRQMASKA);
40 ioc_writeb(val & ~mask, IOC_IRQMASKA);
41 ioc_writeb(mask, IOC_IRQCLRA);
42 a_stf();
43}
44
45static void arc_mask_irq_a(unsigned int irq)
46{
47 unsigned int val, mask;
48
49 mask = 1 << irq;
50 a_clf();
51 val = ioc_readb(IOC_IRQMASKA);
52 ioc_writeb(val & ~mask, IOC_IRQMASKA);
53 a_stf();
54}
55
56static void arc_unmask_irq_a(unsigned int irq)
57{
58 unsigned int val, mask;
59
60 mask = 1 << irq;
61 a_clf();
62 val = ioc_readb(IOC_IRQMASKA);
63 ioc_writeb(val | mask, IOC_IRQMASKA);
64 a_stf();
65}
66
67static struct irqchip arc_a_chip = {
68 .ack = arc_ack_irq_a,
69 .mask = arc_mask_irq_a,
70 .unmask = arc_unmask_irq_a,
71};
72
73static void arc_mask_irq_b(unsigned int irq)
74{
75 unsigned int val, mask;
76 mask = 1 << (irq & 7);
77 val = ioc_readb(IOC_IRQMASKB);
78 ioc_writeb(val & ~mask, IOC_IRQMASKB);
79}
80
81static void arc_unmask_irq_b(unsigned int irq)
82{
83 unsigned int val, mask;
84
85 mask = 1 << (irq & 7);
86 val = ioc_readb(IOC_IRQMASKB);
87 ioc_writeb(val | mask, IOC_IRQMASKB);
88}
89
90static struct irqchip arc_b_chip = {
91 .ack = arc_mask_irq_b,
92 .mask = arc_mask_irq_b,
93 .unmask = arc_unmask_irq_b,
94};
95
96/* FIXME - JMA none of these functions are used in arm26 currently
97static void arc_mask_irq_fiq(unsigned int irq)
98{
99 unsigned int val, mask;
100
101 mask = 1 << (irq & 7);
102 val = ioc_readb(IOC_FIQMASK);
103 ioc_writeb(val & ~mask, IOC_FIQMASK);
104}
105
106static void arc_unmask_irq_fiq(unsigned int irq)
107{
108 unsigned int val, mask;
109
110 mask = 1 << (irq & 7);
111 val = ioc_readb(IOC_FIQMASK);
112 ioc_writeb(val | mask, IOC_FIQMASK);
113}
114
115static struct irqchip arc_fiq_chip = {
116 .ack = arc_mask_irq_fiq,
117 .mask = arc_mask_irq_fiq,
118 .unmask = arc_unmask_irq_fiq,
119};
120*/
121
122void __init arc_init_irq(void)
123{
124 unsigned int irq, flags;
125
126 /* Disable all IOC interrupt sources */
127 ioc_writeb(0, IOC_IRQMASKA);
128 ioc_writeb(0, IOC_IRQMASKB);
129 ioc_writeb(0, IOC_FIQMASK);
130
131 for (irq = 0; irq < NR_IRQS; irq++) {
132 flags = IRQF_VALID;
133
134 if (irq <= 6 || (irq >= 9 && irq <= 15))
135 flags |= IRQF_PROBE;
136
137 if (irq == IRQ_KEYBOARDTX)
138 flags |= IRQF_NOAUTOEN;
139
140 switch (irq) {
141 case 0 ... 7:
142 set_irq_chip(irq, &arc_a_chip);
143 set_irq_handler(irq, do_level_IRQ);
144 set_irq_flags(irq, flags);
145 break;
146
147 case 8 ... 15:
148 set_irq_chip(irq, &arc_b_chip);
149 set_irq_handler(irq, do_level_IRQ);
150 set_irq_flags(irq, flags);
151
152/* case 64 ... 72:
153 set_irq_chip(irq, &arc_fiq_chip);
154 set_irq_flags(irq, flags);
155 break;
156*/
157
158 }
159 }
160
161 irq_desc[IRQ_KEYBOARDTX].noautoenable = 1;
162
163 init_FIQ();
164}
165
diff --git a/arch/arm26/machine/latches.c b/arch/arm26/machine/latches.c
new file mode 100644
index 000000000000..94f05d2a3b2b
--- /dev/null
+++ b/arch/arm26/machine/latches.c
@@ -0,0 +1,72 @@
1/*
2 * linux/arch/arm26/kernel/latches.c
3 *
4 * Copyright (C) David Alan Gilbert 1995/1996,2000
5 * Copyright (C) Ian Molton 2003
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * Support for the latches on the old Archimedes which control the floppy,
12 * hard disc and printer
13 */
14#include <linux/module.h>
15#include <linux/kernel.h>
16#include <linux/init.h>
17#include <linux/sched.h>
18
19#include <asm/io.h>
20#include <asm/hardware.h>
21#include <asm/mach-types.h>
22#include <asm/oldlatches.h>
23
24static unsigned char latch_a_copy;
25static unsigned char latch_b_copy;
26
27/* newval=(oldval & ~mask)|newdata */
28void oldlatch_aupdate(unsigned char mask,unsigned char newdata)
29{
30 unsigned long flags;
31
32 BUG_ON(!machine_is_archimedes());
33
34 local_irq_save(flags); //FIXME: was local_save_flags
35 latch_a_copy = (latch_a_copy & ~mask) | newdata;
36 __raw_writeb(latch_a_copy, LATCHA_BASE);
37 local_irq_restore(flags);
38
39 printk("Latch: A = 0x%02x\n", latch_a_copy);
40}
41
42
43/* newval=(oldval & ~mask)|newdata */
44void oldlatch_bupdate(unsigned char mask,unsigned char newdata)
45{
46 unsigned long flags;
47
48 BUG_ON(!machine_is_archimedes());
49
50
51 local_irq_save(flags);//FIXME: was local_save_flags
52 latch_b_copy = (latch_b_copy & ~mask) | newdata;
53 __raw_writeb(latch_b_copy, LATCHB_BASE);
54 local_irq_restore(flags);
55
56 printk("Latch: B = 0x%02x\n", latch_b_copy);
57}
58
59static int __init oldlatch_init(void)
60{
61 if (machine_is_archimedes()) {
62 oldlatch_aupdate(0xff, 0xff);
63 /* Thats no FDC reset...*/
64 oldlatch_bupdate(0xff, LATCHB_FDCRESET);
65 }
66 return 0;
67}
68
69arch_initcall(oldlatch_init);
70
71EXPORT_SYMBOL(oldlatch_aupdate);
72EXPORT_SYMBOL(oldlatch_bupdate);