blob: e2561d99a3feaf12d9d54d948cf2403fc18a8d5c [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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 * Copyright (C) 1996, 1997, 1998, 2003 by Ralf Baechle
7 */
8#ifndef __ASM_MACH_GENERIC_FLOPPY_H
9#define __ASM_MACH_GENERIC_FLOPPY_H
10
11#include <linux/delay.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070012#include <linux/ioport.h>
13#include <linux/sched.h>
14#include <linux/linkage.h>
15#include <linux/types.h>
16#include <linux/mm.h>
17
18#include <asm/bootinfo.h>
19#include <asm/cachectl.h>
20#include <asm/dma.h>
21#include <asm/floppy.h>
22#include <asm/io.h>
23#include <asm/irq.h>
24#include <asm/pgtable.h>
25
26/*
27 * How to access the FDC's registers.
28 */
29static inline unsigned char fd_inb(unsigned int port)
30{
31 return inb_p(port);
32}
33
34static inline void fd_outb(unsigned char value, unsigned int port)
35{
36 outb_p(value, port);
37}
38
39/*
40 * How to access the floppy DMA functions.
41 */
42static inline void fd_enable_dma(void)
43{
44 enable_dma(FLOPPY_DMA);
45}
46
47static inline void fd_disable_dma(void)
48{
49 disable_dma(FLOPPY_DMA);
50}
51
52static inline int fd_request_dma(void)
53{
54 return request_dma(FLOPPY_DMA, "floppy");
55}
56
57static inline void fd_free_dma(void)
58{
59 free_dma(FLOPPY_DMA);
60}
61
62static inline void fd_clear_dma_ff(void)
63{
64 clear_dma_ff(FLOPPY_DMA);
65}
66
67static inline void fd_set_dma_mode(char mode)
68{
69 set_dma_mode(FLOPPY_DMA, mode);
70}
71
72static inline void fd_set_dma_addr(char *addr)
73{
74 set_dma_addr(FLOPPY_DMA, (unsigned long) addr);
75}
76
77static inline void fd_set_dma_count(unsigned int count)
78{
79 set_dma_count(FLOPPY_DMA, count);
80}
81
82static inline int fd_get_dma_residue(void)
83{
84 return get_dma_residue(FLOPPY_DMA);
85}
86
87static inline void fd_enable_irq(void)
88{
89 enable_irq(FLOPPY_IRQ);
90}
91
92static inline void fd_disable_irq(void)
93{
94 disable_irq(FLOPPY_IRQ);
95}
96
97static inline int fd_request_irq(void)
98{
99 return request_irq(FLOPPY_IRQ, floppy_interrupt,
Ralf Baechle70342282013-01-22 12:59:30 +0100100 0, "floppy", NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101}
102
103static inline void fd_free_irq(void)
104{
105 free_irq(FLOPPY_IRQ, NULL);
106}
107
Ralf Baechle70342282013-01-22 12:59:30 +0100108#define fd_free_irq() free_irq(FLOPPY_IRQ, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109
110
111static inline unsigned long fd_getfdaddr1(void)
112{
113 return 0x3f0;
114}
115
116static inline unsigned long fd_dma_mem_alloc(unsigned long size)
117{
118 unsigned long mem;
119
120 mem = __get_dma_pages(GFP_KERNEL, get_order(size));
121
122 return mem;
123}
124
125static inline void fd_dma_mem_free(unsigned long addr, unsigned long size)
126{
127 free_pages(addr, get_order(size));
128}
129
130static inline unsigned long fd_drive_type(unsigned long n)
131{
132 if (n == 0)
133 return 4; /* 3,5", 1.44mb */
134
135 return 0;
136}
137
138#endif /* __ASM_MACH_GENERIC_FLOPPY_H */