make oldconfig will rebuild these...
[linux-2.4.21-pre4.git] / include / asm-mips / ide.h
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  * This file contains the MIPS architecture specific IDE code.
7  *
8  * Copyright (C) 1994-1996  Linus Torvalds & authors
9  */
10
11 #ifndef __ASM_IDE_H
12 #define __ASM_IDE_H
13
14 #ifdef __KERNEL__
15
16 #include <linux/config.h>
17 #include <asm/io.h>
18
19 #ifndef MAX_HWIFS
20 # ifdef CONFIG_BLK_DEV_IDEPCI
21 #define MAX_HWIFS       10
22 # else
23 #define MAX_HWIFS       6
24 # endif
25 #endif
26
27 struct ide_ops {
28         int (*ide_default_irq)(ide_ioreg_t base);
29         ide_ioreg_t (*ide_default_io_base)(int index);
30         void (*ide_init_hwif_ports)(hw_regs_t *hw, ide_ioreg_t data_port,
31                                     ide_ioreg_t ctrl_port, int *irq);
32 };
33
34 extern struct ide_ops *ide_ops;
35
36 static __inline__ int ide_default_irq(ide_ioreg_t base)
37 {
38         return ide_ops->ide_default_irq(base);
39 }
40
41 static __inline__ ide_ioreg_t ide_default_io_base(int index)
42 {
43         return ide_ops->ide_default_io_base(index);
44 }
45
46 static inline void ide_init_hwif_ports(hw_regs_t *hw, ide_ioreg_t data_port,
47                                        ide_ioreg_t ctrl_port, int *irq)
48 {
49         ide_ops->ide_init_hwif_ports(hw, data_port, ctrl_port, irq);
50 }
51
52 static __inline__ void ide_init_default_hwifs(void)
53 {
54 #ifndef CONFIG_BLK_DEV_IDEPCI
55         hw_regs_t hw;
56         int index;
57
58         for(index = 0; index < MAX_HWIFS; index++) {
59                 ide_init_hwif_ports(&hw, ide_default_io_base(index), 0, NULL);
60                 hw.irq = ide_default_irq(ide_default_io_base(index));
61                 ide_register_hw(&hw, NULL);
62         }
63 #endif /* CONFIG_BLK_DEV_IDEPCI */
64 }
65
66 #undef  SUPPORT_VLB_SYNC
67 #define SUPPORT_VLB_SYNC 0
68
69 #if defined(__MIPSEB__)
70
71 /* get rid of defs from io.h - ide has its private and conflicting versions */
72 #ifdef insw
73 #undef insw
74 #endif
75 #ifdef outsw
76 #undef outsw
77 #endif
78 #ifdef insl
79 #undef insl
80 #endif
81 #ifdef outsl
82 #undef outsl
83 #endif
84
85 #define insw(port, addr, count) ide_insw(port, addr, count)
86 #define insl(port, addr, count) ide_insl(port, addr, count)
87 #define outsw(port, addr, count) ide_outsw(port, addr, count)
88 #define outsl(port, addr, count) ide_outsl(port, addr, count)
89
90 static inline void ide_insw(unsigned long port, void *addr, unsigned int count)
91 {
92         while (count--) {
93                 *(u16 *)addr = *(volatile u16 *)(mips_io_port_base + port);
94                 addr += 2;
95         }
96 }
97
98 static inline void ide_outsw(unsigned long port, void *addr, unsigned int count)
99 {
100         while (count--) {
101                 *(volatile u16 *)(mips_io_port_base + (port)) = *(u16 *)addr;
102                 addr += 2;
103         }
104 }
105
106 static inline void ide_insl(unsigned long port, void *addr, unsigned int count)
107 {
108         while (count--) {
109                 *(u32 *)addr = *(volatile u32 *)(mips_io_port_base + port);
110                 addr += 4;
111         }
112 }
113
114 static inline void ide_outsl(unsigned long port, void *addr, unsigned int count)
115 {
116         while (count--) {
117                 *(volatile u32 *)(mips_io_port_base + (port)) = *(u32 *)addr;
118                 addr += 4;
119         }
120 }
121
122 #endif
123
124 #endif /* __KERNEL__ */
125
126 #endif /* __ASM_IDE_H */