Import 2.3.9pre5
[davej-history.git] / arch / mips / jazz / floppy-jazz.c
blob92c1f95062f204393617d59517ced7e834e56818
1 /* $Id: floppy-jazz.c,v 1.1 1998/05/07 18:38:29 ralf Exp $
3 * This file is subject to the terms and conditions of the GNU General Public
4 * License. See the file "COPYING" in the main directory of this archive
5 * for more details.
7 * Low-level floppy stuff for Jazz family machines.
9 * Copyright (C) 1998 by Ralf Baechle
11 #include <linux/delay.h>
12 #include <linux/init.h>
13 #include <linux/linkage.h>
14 #include <linux/types.h>
15 #include <linux/mm.h>
16 #include <asm/addrspace.h>
17 #include <asm/jazz.h>
18 #include <asm/jazzdma.h>
19 #include <asm/keyboard.h>
20 #include <asm/pgtable.h>
21 #include <asm/floppy.h>
23 static unsigned char jazz_fd_inb(unsigned int port)
25 unsigned char c;
27 c = *(volatile unsigned char *) port;
28 udelay(1);
30 return c;
33 static void jazz_fd_outb(unsigned char value, unsigned int port)
35 *(volatile unsigned char *) port = value;
39 * How to access the floppy DMA functions.
41 static void jazz_fd_enable_dma(int channel)
43 vdma_enable(JAZZ_FLOPPY_DMA);
46 static void jazz_fd_disable_dma(int channel)
48 vdma_disable(JAZZ_FLOPPY_DMA);
51 static int jazz_fd_request_dma(int channel)
53 return 0;
56 static void jazz_fd_free_dma(int channel)
60 static void jazz_fd_clear_dma_ff(int channel)
64 static void jazz_fd_set_dma_mode(int channel, char mode)
66 vdma_set_mode(JAZZ_FLOPPY_DMA, mode);
69 static void jazz_fd_set_dma_addr(int channel, unsigned int a)
71 vdma_set_addr(JAZZ_FLOPPY_DMA, vdma_phys2log(PHYSADDR(a)));
74 static void jazz_fd_set_dma_count(int channel, unsigned int count)
76 vdma_set_count(JAZZ_FLOPPY_DMA, count);
79 static int jazz_fd_get_dma_residue(int channel)
81 return vdma_get_residue(JAZZ_FLOPPY_DMA);
84 static void jazz_fd_enable_irq(int irq)
88 static void jazz_fd_disable_irq(int irq)
92 static unsigned long jazz_fd_getfdaddr1(void)
94 return JAZZ_FDC_BASE;
97 /* Pure 2^n version of get_order */
98 extern inline int __get_order(unsigned long size)
100 int order;
102 size = (size-1) >> (PAGE_SHIFT-1);
103 order = -1;
104 do {
105 size >>= 1;
106 order++;
107 } while (size);
108 return order;
111 static unsigned long jazz_fd_dma_mem_alloc(unsigned long size)
113 int order = __get_order(size);
114 unsigned long mem;
116 mem = __get_dma_pages(GFP_KERNEL, order);
117 if(!mem)
118 return 0;
119 vdma_alloc(PHYSADDR(mem), size); /* XXX error checking */
121 return mem;
124 static void jazz_fd_dma_mem_free(unsigned long addr,
125 unsigned long size)
127 vdma_free(vdma_phys2log(PHYSADDR(addr)));
128 free_pages(addr, __get_order(size));
131 static unsigned long jazz_fd_drive_type(unsigned long n)
133 /* XXX This is wrong for machines with ED 2.88mb disk drives like the
134 Olivetti M700. Anyway, we should suck this from the ARC
135 firmware. */
136 if (n == 0)
137 return 4; /* 3,5", 1.44mb */
139 return 0;
142 struct fd_ops jazz_fd_ops = {
144 * How to access the floppy controller's ports
146 jazz_fd_inb,
147 jazz_fd_outb,
149 * How to access the floppy DMA functions.
151 jazz_fd_enable_dma,
152 jazz_fd_disable_dma,
153 jazz_fd_request_dma,
154 jazz_fd_free_dma,
155 jazz_fd_clear_dma_ff,
156 jazz_fd_set_dma_mode,
157 jazz_fd_set_dma_addr,
158 jazz_fd_set_dma_count,
159 jazz_fd_get_dma_residue,
160 jazz_fd_enable_irq,
161 jazz_fd_disable_irq,
162 jazz_fd_getfdaddr1,
163 jazz_fd_dma_mem_alloc,
164 jazz_fd_dma_mem_free,
165 jazz_fd_drive_type