import of upstream 2.4.34.4 from kernel.org
[linux-2.4.git] / arch / mips / jazz / floppy-jazz.c
1 /*
2  * This file is subject to the terms and conditions of the GNU General Public
3  * License.  See the file "COPYING" in the main directory of this archive
4  * for more details.
5  *
6  * Low-level floppy stuff for Jazz family machines.
7  *
8  * Copyright (C) 1998 by Ralf Baechle
9  */
10 #include <linux/delay.h>
11 #include <linux/init.h>
12 #include <linux/linkage.h>
13 #include <linux/types.h>
14 #include <linux/mm.h>
15 #include <asm/addrspace.h>
16 #include <asm/jazz.h>
17 #include <asm/jazzdma.h>
18 #include <asm/keyboard.h>
19 #include <asm/pgtable.h>
20 #include <asm/floppy.h>
21
22 static unsigned char jazz_fd_inb(unsigned int port)
23 {
24         unsigned char c;
25
26         c = *(volatile unsigned char *) port;
27         udelay(1);
28
29         return c;
30 }
31
32 static void jazz_fd_outb(unsigned char value, unsigned int port)
33 {
34         *(volatile unsigned char *) port = value;
35 }
36
37 /*
38  * How to access the floppy DMA functions.
39  */
40 static void jazz_fd_enable_dma(int channel)
41 {
42         vdma_enable(JAZZ_FLOPPY_DMA);
43 }
44
45 static void jazz_fd_disable_dma(int channel)
46 {
47         vdma_disable(JAZZ_FLOPPY_DMA);
48 }
49
50 static int jazz_fd_request_dma(int channel)
51 {
52         return 0;
53 }
54
55 static void jazz_fd_free_dma(int channel)
56 {
57 }
58
59 static void jazz_fd_clear_dma_ff(int channel)
60 {
61 }
62
63 static void jazz_fd_set_dma_mode(int channel, char mode)
64 {
65         vdma_set_mode(JAZZ_FLOPPY_DMA, mode);
66 }
67
68 static void jazz_fd_set_dma_addr(int channel, unsigned int a)
69 {
70         vdma_set_addr(JAZZ_FLOPPY_DMA, vdma_phys2log(PHYSADDR(a)));
71 }
72
73 static void jazz_fd_set_dma_count(int channel, unsigned int count)
74 {
75         vdma_set_count(JAZZ_FLOPPY_DMA, count);
76 }
77
78 static int jazz_fd_get_dma_residue(int channel)
79 {
80         return vdma_get_residue(JAZZ_FLOPPY_DMA);
81 }
82
83 static void jazz_fd_enable_irq(int irq)
84 {
85 }
86
87 static void jazz_fd_disable_irq(int irq)
88 {
89 }
90
91 static unsigned long jazz_fd_getfdaddr1(void)
92 {
93         return JAZZ_FDC_BASE;
94 }
95
96 static unsigned long jazz_fd_dma_mem_alloc(unsigned long size)
97 {
98         unsigned long mem;
99
100         mem = __get_dma_pages(GFP_KERNEL, get_order(size));
101         if(!mem)
102                 return 0;
103         vdma_alloc(PHYSADDR(mem), size);        /* XXX error checking */
104
105         return mem;
106 }
107
108 static void jazz_fd_dma_mem_free(unsigned long addr,
109                                         unsigned long size)
110 {
111         vdma_free(vdma_phys2log(PHYSADDR(addr)));
112         free_pages(addr, get_order(size));
113 }
114
115 static unsigned long jazz_fd_drive_type(unsigned long n)
116 {
117         /* XXX This is wrong for machines with ED 2.88mb disk drives like the
118            Olivetti M700.  Anyway, we should suck this from the ARC
119            firmware.  */
120         if (n == 0)
121                 return 4;       /* 3,5", 1.44mb */
122
123         return 0;
124 }
125
126 struct fd_ops jazz_fd_ops = {
127         /*
128          * How to access the floppy controller's ports
129          */
130         jazz_fd_inb,
131         jazz_fd_outb,
132         /*
133          * How to access the floppy DMA functions.
134          */
135         jazz_fd_enable_dma,
136         jazz_fd_disable_dma,
137         jazz_fd_request_dma,
138         jazz_fd_free_dma,
139         jazz_fd_clear_dma_ff,
140         jazz_fd_set_dma_mode,
141         jazz_fd_set_dma_addr,
142         jazz_fd_set_dma_count,
143         jazz_fd_get_dma_residue,
144         jazz_fd_enable_irq,
145         jazz_fd_disable_irq,
146         jazz_fd_getfdaddr1,
147         jazz_fd_dma_mem_alloc,
148         jazz_fd_dma_mem_free,
149         jazz_fd_drive_type
150 };