This source file includes following definitions.
- qd6560b_selectproc
- try_to_init_ht6560b
- tune_ht6560b
- init_ht6560b
1
2
3
4
5
6
7 #undef REALLY_SLOW_IO
8
9 #include <linux/types.h>
10 #include <linux/kernel.h>
11 #include <linux/delay.h>
12 #include <linux/timer.h>
13 #include <linux/mm.h>
14 #include <linux/ioport.h>
15 #include <linux/blkdev.h>
16 #include <linux/hdreg.h>
17 #include <asm/io.h>
18 #include "ide.h"
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 static byte qd6560b_selects [2][MAX_DRIVES] = {{0x3c,0x3c}, {0x3d,0x3d}};
39
40 static void qd6560b_selectproc (ide_drive_t *drive)
41 {
42 static byte current_select = 0;
43 byte drive_select = qd6560b_selects[HWIF(drive)->index][drive->select.b.unit];
44
45 if (drive_select != current_select) {
46 byte t;
47 unsigned long flags;
48 save_flags (flags);
49 cli();
50 current_select = drive_select;
51 (void) inb(0x3e6);
52 (void) inb(0x3e6);
53 (void) inb(0x3e6);
54
55
56
57 t = inb(0x3e6) ^ 0x3f;
58 t &= (~0x21);
59 t |= (current_select & 0x21);
60 outb(t,0x3e6);
61 restore_flags (flags);
62 }
63 }
64
65
66
67
68 int try_to_init_ht6560b(void)
69 {
70 byte orig_value;
71 int i;
72
73
74 if ((orig_value=inb(0x3e6)) == 0xff)
75 return 0;
76
77 for (i=3;i>0;i--) {
78 outb(0x00,0x3e6);
79 if (!( (~inb(0x3e6)) & 0x3f )) {
80 outb(orig_value,0x3e6);
81 return 0;
82 }
83 }
84 outb(0x00,0x3e6);
85 if ((~inb(0x3e6))& 0x3f) {
86 outb(orig_value,0x3e6);
87 return 0;
88 }
89
90
91
92
93
94 outb((orig_value ^ 0x3f) & 0xfd,0x3e6);
95 printk("ht6560b: detected and initialized\n");
96 return 1;
97 }
98
99 static void tune_ht6560b (ide_drive_t *drive, byte pio)
100 {
101 unsigned int hwif, unit;
102
103 if (pio == 255) {
104 if (drive->media != ide_disk) {
105 pio = 0;
106 } else {
107 struct hd_driveid *id = drive->id;
108 pio = id->tPIO;
109 if ((id->field_valid & 0x02) && (id->eide_pio_modes & 0x01))
110 pio = 3;
111 }
112 }
113 hwif = HWIF(drive)->index;
114 unit = drive->select.b.unit;
115 if (pio < 3)
116 qd6560b_selects[hwif][unit] |= 0x20;
117 else
118 qd6560b_selects[hwif][unit] &= ~0x20;
119 }
120
121 void init_ht6560b (void)
122 {
123 if (check_region(0x3e6,1)) {
124 printk("\nht6560b: PORT 0x3e6 ALREADY IN USE\n");
125 } else {
126 if (try_to_init_ht6560b()) {
127 request_region(0x3e6, 1, "ht6560b");
128 ide_hwifs[0].chipset = ide_ht6560b;
129 ide_hwifs[1].chipset = ide_ht6560b;
130 ide_hwifs[0].selectproc = &qd6560b_selectproc;
131 ide_hwifs[1].selectproc = &qd6560b_selectproc;
132 ide_hwifs[0].tuneproc = &tune_ht6560b;
133 ide_hwifs[1].tuneproc = &tune_ht6560b;
134 ide_hwifs[0].serialized = 1;
135 }
136 }
137 }