ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / include / asm-i386 / ide.h
1 /*
2  *  linux/include/asm-i386/ide.h
3  *
4  *  Copyright (C) 1994-1996  Linus Torvalds & authors
5  */
6
7 /*
8  *  This file contains the i386 architecture specific IDE code.
9  */
10
11 #ifndef __ASMi386_IDE_H
12 #define __ASMi386_IDE_H
13
14 #ifdef __KERNEL__
15
16 #include <linux/config.h>
17
18 #ifndef MAX_HWIFS
19 # ifdef CONFIG_BLK_DEV_IDEPCI
20 #define MAX_HWIFS       10
21 # else
22 #define MAX_HWIFS       6
23 # endif
24 #endif
25
26 static __inline__ int ide_default_irq(unsigned long base)
27 {
28         switch (base) {
29 #ifdef CONFIG_X86_PC9800
30                 case 0x640: return 9;
31 #endif
32                 case 0x1f0: return 14;
33                 case 0x170: return 15;
34                 case 0x1e8: return 11;
35                 case 0x168: return 10;
36                 case 0x1e0: return 8;
37                 case 0x160: return 12;
38                 default:
39                         return 0;
40         }
41 }
42
43 static __inline__ unsigned long ide_default_io_base(int index)
44 {
45         switch (index) {
46 #ifdef CONFIG_X86_PC9800
47                 case 0:
48                 case 1: return 0x640;
49 #else
50                 case 0: return 0x1f0;
51                 case 1: return 0x170;
52                 case 2: return 0x1e8;
53                 case 3: return 0x168;
54                 case 4: return 0x1e0;
55                 case 5: return 0x160;
56 #endif
57                 default:
58                         return 0;
59         }
60 }
61
62 #ifdef CONFIG_X86_PC9800
63 static __inline__ void ide_init_hwif_ports(hw_regs_t *hw, unsigned long data_port,
64          unsigned long ctrl_port, int *irq)
65 {
66         unsigned long reg = data_port;
67         int i;
68
69         unsigned long increment = data_port == 0x640 ? 2 : 1;
70
71         for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) {
72                 hw->io_ports[i] = reg;
73                 reg += increment;
74         }
75         if (ctrl_port) {
76                 hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port;
77         } else if (data_port == 0x640) {
78                 hw->io_ports[IDE_CONTROL_OFFSET] = 0x74c;
79         } else {
80                 hw->io_ports[IDE_CONTROL_OFFSET] = hw->io_ports[IDE_DATA_OFFSET] + 0x206;
81         }
82         if (irq != NULL)
83                 *irq = 0;
84         hw->io_ports[IDE_IRQ_OFFSET] = 0;
85 }
86 #endif
87
88 #ifdef CONFIG_BLK_DEV_IDEPCI
89 #define ide_init_default_irq(base)      (0)
90 #else
91 #define ide_init_default_irq(base)      ide_default_irq(base)
92 #endif
93
94 #include <asm-generic/ide_iops.h>
95
96 #endif /* __KERNEL__ */
97
98 #endif /* __ASMi386_IDE_H */