* added 0.99 linux version
[mascara-docs.git] / i386 / linux / linux-2.3.21 / arch / arm / kernel / dma-isa.c
blobf5f98bbac4520cf228e2f514c9f33934023be7ed
1 /*
2 * arch/arm/kernel/dma-isa.c: ISA DMA primitives
4 * Copyright (C) Russell King
6 * Taken from various sources, including:
7 * linux/include/asm/dma.h: Defines for using and allocating dma channels.
8 * Written by Hennus Bergman, 1992.
9 * High DMA channel support & info by Hannu Savolainen and John Boyd, Nov. 1992.
10 * arch/arm/kernel/dma-ebsa285.c
11 * Copyright (C) 1998 Phil Blundell
13 #include <linux/sched.h>
14 #include <linux/ioport.h>
15 #include <linux/init.h>
17 #include <asm/dma.h>
18 #include <asm/io.h>
20 #include "dma.h"
21 #include "dma-isa.h"
23 #define ISA_DMA_MODE_READ 0x44
24 #define ISA_DMA_MODE_WRITE 0x48
25 #define ISA_DMA_MODE_CASCADE 0xc0
26 #define ISA_DMA_AUTOINIT 0x10
28 #define ISA_DMA_MASK 0
29 #define ISA_DMA_MODE 1
30 #define ISA_DMA_CLRFF 2
31 #define ISA_DMA_PGHI 3
32 #define ISA_DMA_PGLO 4
33 #define ISA_DMA_ADDR 5
34 #define ISA_DMA_COUNT 6
36 static unsigned int isa_dma_port[8][7] = {
37 /* MASK MODE CLRFF PAGE_HI PAGE_LO ADDR COUNT */
38 { 0x0a, 0x0b, 0x0c, 0x487, 0x087, 0x00, 0x01 },
39 { 0x0a, 0x0b, 0x0c, 0x483, 0x083, 0x02, 0x03 },
40 { 0x0a, 0x0b, 0x0c, 0x481, 0x081, 0x04, 0x05 },
41 { 0x0a, 0x0b, 0x0c, 0x482, 0x082, 0x06, 0x07 },
42 { 0xd4, 0xd6, 0xd8, 0x000, 0x000, 0xc0, 0xc2 },
43 { 0xd4, 0xd6, 0xd8, 0x48b, 0x08b, 0xc4, 0xc6 },
44 { 0xd4, 0xd6, 0xd8, 0x489, 0x089, 0xc8, 0xca },
45 { 0xd4, 0xd6, 0xd8, 0x48a, 0x08a, 0xcc, 0xce }
48 int isa_request_dma(int channel, dma_t *dma, const char *dev_name)
50 return 0;
53 void isa_free_dma(int channel, dma_t *dma)
55 /* nothing to do */
58 int isa_get_dma_residue(int channel, dma_t *dma)
60 unsigned int io_port = isa_dma_port[channel][ISA_DMA_COUNT];
61 int count;
63 count = 1 + inb(io_port);
64 count |= inb(io_port) << 8;
66 return channel < 4 ? count : (count << 1);
69 void isa_enable_dma(int channel, dma_t *dma)
71 if (dma->invalid) {
72 unsigned long address, length;
73 unsigned int mode;
75 address = dma->buf.address;
76 length = dma->buf.length - 1;
78 outb(address >> 16, isa_dma_port[channel][ISA_DMA_PGLO]);
79 outb(address >> 24, isa_dma_port[channel][ISA_DMA_PGHI]);
81 if (channel >= 4) {
82 address >>= 1;
83 length >>= 1;
86 outb(0, isa_dma_port[channel][ISA_DMA_CLRFF]);
88 outb(address, isa_dma_port[channel][ISA_DMA_ADDR]);
89 outb(address >> 8, isa_dma_port[channel][ISA_DMA_ADDR]);
91 outb(length, isa_dma_port[channel][ISA_DMA_COUNT]);
92 outb(length >> 8, isa_dma_port[channel][ISA_DMA_COUNT]);
94 mode = channel & 3;
96 switch (dma->dma_mode & DMA_MODE_MASK) {
97 case DMA_MODE_READ:
98 mode |= ISA_DMA_MODE_READ;
99 dma_cache_inv(__bus_to_virt(dma->buf.address), dma->buf.length);
100 break;
102 case DMA_MODE_WRITE:
103 mode |= ISA_DMA_MODE_WRITE;
104 dma_cache_wback(__bus_to_virt(dma->buf.address), dma->buf.length);
105 break;
107 case DMA_MODE_CASCADE:
108 mode |= ISA_DMA_MODE_CASCADE;
109 break;
111 default:
112 break;
115 if (dma->dma_mode & DMA_AUTOINIT)
116 mode |= ISA_DMA_AUTOINIT;
118 outb(mode, isa_dma_port[channel][ISA_DMA_MODE]);
119 dma->invalid = 0;
121 outb(channel & 3, isa_dma_port[channel][ISA_DMA_MASK]);
124 void isa_disable_dma(int channel, dma_t *dma)
126 outb(channel | 4, isa_dma_port[channel][ISA_DMA_MASK]);
129 int __init isa_init_dma(void)
131 int dmac_found;
133 outb(0xff, 0x0d);
134 outb(0xff, 0xda);
136 outb(0x55, 0x00);
137 outb(0xaa, 0x00);
139 dmac_found = inb(0x00) == 0x55 && inb(0x00) == 0xaa;
141 if (dmac_found) {
142 int channel, i;
144 for (channel = 0; channel < 8; channel++)
145 isa_disable_dma(channel, NULL);
147 outb(0x40, 0x0b);
148 outb(0x41, 0x0b);
149 outb(0x42, 0x0b);
150 outb(0x43, 0x0b);
152 outb(0xc0, 0xd6);
153 outb(0x41, 0xd6);
154 outb(0x42, 0xd6);
155 outb(0x43, 0xd6);
157 outb(0, 0xd4);
159 outb(0x10, 0x08);
160 outb(0x10, 0xd0);
163 * Is this correct? According to
164 * my documentation, it doesn't
165 * appear to be. It should be
166 * outb(0x3f, 0x40b); outb(0x3f, 0x4d6);
168 outb(0x30, 0x40b);
169 outb(0x31, 0x40b);
170 outb(0x32, 0x40b);
171 outb(0x33, 0x40b);
172 outb(0x31, 0x4d6);
173 outb(0x32, 0x4d6);
174 outb(0x33, 0x4d6);
176 request_dma(DMA_ISA_CASCADE, "cascade");
178 for (i = 0; i < sizeof(dma_resources) / sizeof(dma_resources[0]); i++)
179 request_resource(&ioport_resource, dma_resources + i);
182 return dmac_found;