Rev 422 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
422 | giacomo | 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 | static __inline__ void ide_init_hwif_ports(hw_regs_t *hw, unsigned long data_port, |
||
63 | unsigned long ctrl_port, int *irq) |
||
64 | { |
||
65 | unsigned long reg = data_port; |
||
66 | int i; |
||
67 | #ifdef CONFIG_X86_PC9800 |
||
68 | unsigned long increment = data_port == 0x640 ? 2 : 1; |
||
69 | #endif |
||
70 | |||
71 | for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) { |
||
72 | hw->io_ports[i] = reg; |
||
73 | #ifdef CONFIG_X86_PC9800 |
||
74 | reg += increment; |
||
75 | #else |
||
76 | reg += 1; |
||
77 | #endif |
||
78 | } |
||
79 | if (ctrl_port) { |
||
80 | hw->io_ports[IDE_CONTROL_OFFSET] = ctrl_port; |
||
81 | #ifdef CONFIG_X86_PC9800 |
||
82 | } else if (data_port == 0x640) { |
||
83 | hw->io_ports[IDE_CONTROL_OFFSET] = 0x74c; |
||
84 | #endif |
||
85 | } else { |
||
86 | hw->io_ports[IDE_CONTROL_OFFSET] = hw->io_ports[IDE_DATA_OFFSET] + 0x206; |
||
87 | } |
||
88 | if (irq != NULL) |
||
89 | *irq = 0; |
||
90 | hw->io_ports[IDE_IRQ_OFFSET] = 0; |
||
91 | } |
||
92 | |||
93 | static __inline__ void ide_init_default_hwifs(void) |
||
94 | { |
||
95 | #ifndef CONFIG_BLK_DEV_IDEPCI |
||
96 | hw_regs_t hw; |
||
97 | int index; |
||
98 | |||
99 | for(index = 0; index < MAX_HWIFS; index++) { |
||
100 | memset(&hw, 0, sizeof hw); |
||
101 | ide_init_hwif_ports(&hw, ide_default_io_base(index), 0, NULL); |
||
102 | hw.irq = ide_default_irq(ide_default_io_base(index)); |
||
103 | ide_register_hw(&hw, NULL); |
||
104 | } |
||
105 | #endif /* CONFIG_BLK_DEV_IDEPCI */ |
||
106 | } |
||
107 | |||
108 | #include <asm-generic/ide_iops.h> |
||
109 | |||
110 | #endif /* __KERNEL__ */ |
||
111 | |||
112 | #endif /* __ASMi386_IDE_H */ |