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  * Access the floppy hardware on PC style hardware
7  *
8  * Copyright (C) 1996, 1997, 1998 by Ralf Baechle
9  */
10 #include <linux/delay.h>
11 #include <linux/init.h>
12 #include <linux/ioport.h>
13 #include <linux/sched.h>
14 #include <linux/kernel.h>
15 #include <linux/linkage.h>
16 #include <linux/types.h>
17 #include <linux/mm.h>
18 #include <asm/bootinfo.h>
19 #include <asm/cachectl.h>
20 #include <asm/dma.h>
21 #include <asm/floppy.h>
22 #include <asm/keyboard.h>
23 #include <asm/io.h>
24 #include <asm/irq.h>
25 #include <asm/pgtable.h>
26 
27 /*
28  * How to access the FDC's registers.
29  */
std_fd_inb(unsigned int port)30 static unsigned char std_fd_inb(unsigned int port)
31 {
32 	return inb_p(port);
33 }
34 
std_fd_outb(unsigned char value,unsigned int port)35 static void std_fd_outb(unsigned char value, unsigned int port)
36 {
37 	outb_p(value, port);
38 }
39 
40 /*
41  * How to access the floppy DMA functions.
42  */
std_fd_enable_dma(int channel)43 static void std_fd_enable_dma(int channel)
44 {
45 	enable_dma(channel);
46 }
47 
std_fd_disable_dma(int channel)48 static void std_fd_disable_dma(int channel)
49 {
50 	disable_dma(channel);
51 }
52 
std_fd_request_dma(int channel)53 static int std_fd_request_dma(int channel)
54 {
55 	return request_dma(channel, "floppy");
56 }
57 
std_fd_free_dma(int channel)58 static void std_fd_free_dma(int channel)
59 {
60 	free_dma(channel);
61 }
62 
std_fd_clear_dma_ff(int channel)63 static void std_fd_clear_dma_ff(int channel)
64 {
65 	clear_dma_ff(channel);
66 }
67 
std_fd_set_dma_mode(int channel,char mode)68 static void std_fd_set_dma_mode(int channel, char mode)
69 {
70 	set_dma_mode(channel, mode);
71 }
72 
std_fd_set_dma_addr(int channel,unsigned int addr)73 static void std_fd_set_dma_addr(int channel, unsigned int addr)
74 {
75 	set_dma_addr(channel, addr);
76 }
77 
std_fd_set_dma_count(int channel,unsigned int count)78 static void std_fd_set_dma_count(int channel, unsigned int count)
79 {
80 	set_dma_count(channel, count);
81 }
82 
std_fd_get_dma_residue(int channel)83 static int std_fd_get_dma_residue(int channel)
84 {
85 	return get_dma_residue(channel);
86 }
87 
std_fd_enable_irq(int irq)88 static void std_fd_enable_irq(int irq)
89 {
90 	enable_irq(irq);
91 }
92 
std_fd_disable_irq(int irq)93 static void std_fd_disable_irq(int irq)
94 {
95 	disable_irq(irq);
96 }
97 
std_fd_getfdaddr1(void)98 static unsigned long std_fd_getfdaddr1(void)
99 {
100 	return 0x3f0;
101 }
102 
std_fd_dma_mem_alloc(unsigned long size)103 static unsigned long std_fd_dma_mem_alloc(unsigned long size)
104 {
105 	int order = get_order(size);
106 	unsigned long mem;
107 
108 	mem = __get_dma_pages(GFP_KERNEL,order);
109 
110 	return mem;
111 }
112 
std_fd_dma_mem_free(unsigned long addr,unsigned long size)113 static void std_fd_dma_mem_free(unsigned long addr, unsigned long size)
114 {
115 	free_pages(addr, get_order(size));
116 }
117 
std_fd_drive_type(unsigned long n)118 static unsigned long std_fd_drive_type(unsigned long n)
119 {
120 	if (n == 0)
121 		return 4;	/* 3,5", 1.44mb */
122 
123 	return 0;
124 }
125 
126 struct fd_ops std_fd_ops = {
127 	/*
128 	 * How to access the floppy controller's ports
129 	 */
130 	std_fd_inb,
131 	std_fd_outb,
132 	/*
133 	 * How to access the floppy DMA functions.
134 	 */
135 	std_fd_enable_dma,
136 	std_fd_disable_dma,
137 	std_fd_request_dma,
138 	std_fd_free_dma,
139 	std_fd_clear_dma_ff,
140 	std_fd_set_dma_mode,
141 	std_fd_set_dma_addr,
142 	std_fd_set_dma_count,
143 	std_fd_get_dma_residue,
144 	std_fd_enable_irq,
145 	std_fd_disable_irq,
146         std_fd_getfdaddr1,
147         std_fd_dma_mem_alloc,
148         std_fd_dma_mem_free,
149 	std_fd_drive_type
150 };
151