This source file includes following definitions.
- isp16_setup
- isp16_init
- isp16_detect
- isp16_c928__detect
- isp16_c929__detect
- isp16_cdi_config
- init_module
- cleanup_module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39 #define ISP16_VERSION_MAJOR 0
40 #define ISP16_VERSION_MINOR 6
41
42 #ifdef MODULE
43 #include <linux/module.h>
44 #endif
45
46 #include <linux/fs.h>
47 #include <linux/kernel.h>
48 #include <linux/string.h>
49 #include <linux/ioport.h>
50 #include <linux/isp16.h>
51 #include <asm/io.h>
52
53 static short isp16_detect(void);
54 static short isp16_c928__detect(void);
55 static short isp16_c929__detect(void);
56 static short isp16_cdi_config(int base, u_char drive_type, int irq, int dma);
57 static short isp16_type;
58 static u_char isp16_ctrl;
59 static u_short isp16_enable_port;
60
61 static int isp16_cdrom_base = ISP16_CDROM_IO_BASE;
62 static int isp16_cdrom_irq = ISP16_CDROM_IRQ;
63 static int isp16_cdrom_dma = ISP16_CDROM_DMA;
64 static char *isp16_cdrom_type = ISP16_CDROM_TYPE;
65 #ifdef MODULE
66 int init_module(void);
67 void cleanup_module(void);
68 #endif
69
70 #define ISP16_IN(p) (outb(isp16_ctrl,ISP16_CTRL_PORT), inb(p))
71 #define ISP16_OUT(p,b) (outb(isp16_ctrl,ISP16_CTRL_PORT), outb(b,p))
72
73
74 void
75 isp16_setup(char *str, int *ints)
76 {
77 if ( ints[0] > 0 )
78 isp16_cdrom_base = ints[1];
79 if ( ints[0] > 1 )
80 isp16_cdrom_irq = ints[2];
81 if ( ints[0] > 2 )
82 isp16_cdrom_dma = ints[3];
83 if ( str )
84 isp16_cdrom_type = str;
85 }
86
87
88
89
90
91 int
92 isp16_init(void)
93 {
94 u_char expected_drive;
95
96 printk(KERN_INFO "ISP16: configuration cdrom interface, version %d.%d.\n", ISP16_VERSION_MAJOR,
97 ISP16_VERSION_MINOR);
98
99 if ( !strcmp(isp16_cdrom_type, "noisp16") ) {
100 printk("ISP16: no cdrom interface configured.\n");
101 return(0);
102 }
103
104 if (check_region(ISP16_IO_BASE, ISP16_IO_SIZE)) {
105 printk("ISP16: i/o ports already in use.\n");
106 return(-EIO);
107 }
108
109 if ( (isp16_type=isp16_detect()) < 0 ) {
110 printk("ISP16: no cdrom interface found.\n");
111 return(-EIO);
112 }
113
114 printk(KERN_INFO "ISP16: cdrom interface (with OPTi 82C92%d chip) detected.\n",
115 (isp16_type==2) ? 9 : 8);
116
117 if ( !strcmp(isp16_cdrom_type, "Sanyo") )
118 expected_drive = (isp16_type ? ISP16_SANYO1 : ISP16_SANYO0);
119 else if ( !strcmp(isp16_cdrom_type, "Sony") )
120 expected_drive = ISP16_SONY;
121 else if ( !strcmp(isp16_cdrom_type, "Panasonic") )
122 expected_drive = (isp16_type ? ISP16_PANASONIC1 : ISP16_PANASONIC0);
123 else if ( !strcmp(isp16_cdrom_type, "Mitsumi") )
124 expected_drive = ISP16_MITSUMI;
125 else {
126 printk("ISP16: %s not supported by cdrom interface.\n", isp16_cdrom_type);
127 return(-EIO);
128 }
129
130 if ( isp16_cdi_config(isp16_cdrom_base, expected_drive,
131 isp16_cdrom_irq, isp16_cdrom_dma ) < 0) {
132 printk("ISP16: cdrom interface has not been properly configured.\n");
133 return(-EIO);
134 }
135 printk(KERN_INFO "ISP16: cdrom interface set up with io base 0x%03X, irq %d, dma %d,"
136 " type %s.\n", isp16_cdrom_base, isp16_cdrom_irq, isp16_cdrom_dma,
137 isp16_cdrom_type);
138 return(0);
139 }
140
141 static short
142 isp16_detect(void)
143 {
144
145 if ( isp16_c929__detect() >= 0 )
146 return(2);
147 else
148 return(isp16_c928__detect());
149 }
150
151 static short
152 isp16_c928__detect(void)
153 {
154 u_char ctrl;
155 u_char enable_cdrom;
156 u_char io;
157 short i = -1;
158
159 isp16_ctrl = ISP16_C928__CTRL;
160 isp16_enable_port = ISP16_C928__ENABLE_PORT;
161
162
163
164
165 ctrl = ISP16_IN( ISP16_CTRL_PORT ) & 0xFC;
166 ISP16_OUT( ISP16_CTRL_PORT, ctrl );
167
168
169 enable_cdrom = ISP16_IN( ISP16_C928__ENABLE_PORT ) & 0x38;
170
171 if ( !(enable_cdrom & 0x20) ) {
172
173 io = ISP16_IN( ISP16_IO_SET_PORT ) & 0x03;
174 if ( ((io&0x01)<<1) == (io&0x02) ) {
175 if ( io == 0 ) {
176 i = 0;
177 enable_cdrom |= 0x20;
178 }
179 else {
180 i = 1;
181 enable_cdrom |= 0x28;
182 }
183 ISP16_OUT( ISP16_C928__ENABLE_PORT, enable_cdrom );
184 }
185 else {
186 ISP16_OUT( ISP16_CTRL_PORT, ctrl );
187 return(i);
188 }
189 }
190 else if ( enable_cdrom == 0x20 )
191 i = 0;
192 else if ( enable_cdrom == 0x28 )
193 i = 1;
194
195 ISP16_OUT( ISP16_CTRL_PORT, ctrl );
196
197 return(i);
198 }
199
200 static short
201 isp16_c929__detect(void)
202 {
203 u_char ctrl;
204 u_char tmp;
205
206 isp16_ctrl = ISP16_C929__CTRL;
207 isp16_enable_port = ISP16_C929__ENABLE_PORT;
208
209
210
211
212 ctrl = ISP16_IN( ISP16_CTRL_PORT );
213
214
215 ISP16_OUT( ISP16_CTRL_PORT, 0 );
216 tmp = ISP16_IN( ISP16_CTRL_PORT );
217
218 if ( tmp != 2 )
219 return(-1);
220
221
222 ISP16_OUT( ISP16_CTRL_PORT, ctrl );
223
224 return(2);
225 }
226
227 static short
228 isp16_cdi_config(int base, u_char drive_type, int irq, int dma)
229 {
230 u_char base_code;
231 u_char irq_code;
232 u_char dma_code;
233 u_char i;
234
235 if ( (drive_type == ISP16_MITSUMI) && (dma != 0) )
236 printk("ISP16: Mitsumi cdrom drive has no dma support.\n");
237
238 switch (base) {
239 case 0x340: base_code = ISP16_BASE_340; break;
240 case 0x330: base_code = ISP16_BASE_330; break;
241 case 0x360: base_code = ISP16_BASE_360; break;
242 case 0x320: base_code = ISP16_BASE_320; break;
243 default:
244 printk("ISP16: base address 0x%03X not supported by cdrom interface.\n",
245 base);
246 return(-1);
247 }
248 switch (irq) {
249 case 0: irq_code = ISP16_IRQ_X; break;
250 case 5: irq_code = ISP16_IRQ_5;
251 printk("ISP16: irq 5 shouldn't be used by cdrom interface,"
252 " due to possible conflicts with the sound card.\n");
253 break;
254 case 7: irq_code = ISP16_IRQ_7;
255 printk("ISP16: irq 7 shouldn't be used by cdrom interface,"
256 " due to possible conflicts with the sound card.\n");
257 break;
258 case 3: irq_code = ISP16_IRQ_3; break;
259 case 9: irq_code = ISP16_IRQ_9; break;
260 case 10: irq_code = ISP16_IRQ_10; break;
261 case 11: irq_code = ISP16_IRQ_11; break;
262 default:
263 printk("ISP16: irq %d not supported by cdrom interface.\n", irq );
264 return(-1);
265 }
266 switch (dma) {
267 case 0: dma_code = ISP16_DMA_X; break;
268 case 1: printk("ISP16: dma 1 cannot be used by cdrom interface,"
269 " due to conflict with the sound card.\n");
270 return(-1); break;
271 case 3: dma_code = ISP16_DMA_3; break;
272 case 5: dma_code = ISP16_DMA_5; break;
273 case 6: dma_code = ISP16_DMA_6; break;
274 case 7: dma_code = ISP16_DMA_7; break;
275 default:
276 printk("ISP16: dma %d not supported by cdrom interface.\n", dma);
277 return(-1);
278 }
279
280 if ( drive_type != ISP16_SONY && drive_type != ISP16_PANASONIC0 &&
281 drive_type != ISP16_PANASONIC1 && drive_type != ISP16_SANYO0 &&
282 drive_type != ISP16_SANYO1 && drive_type != ISP16_MITSUMI &&
283 drive_type != ISP16_DRIVE_X ) {
284 printk("ISP16: drive type (code 0x%02X) not supported by cdrom"
285 " interface.\n", drive_type );
286 return(-1);
287 }
288
289
290 i = ISP16_IN(ISP16_DRIVE_SET_PORT) & ISP16_DRIVE_SET_MASK;
291 ISP16_OUT( ISP16_DRIVE_SET_PORT, i|drive_type );
292
293
294 if ( isp16_type > 1 )
295 ISP16_OUT( isp16_enable_port, ISP16_ENABLE_CDROM );
296
297
298 i = ISP16_IN(ISP16_IO_SET_PORT) & ISP16_IO_SET_MASK;
299 ISP16_OUT( ISP16_IO_SET_PORT, i|base_code|irq_code|dma_code );
300
301 return(0);
302 }
303
304 #ifdef MODULE
305 int init_module(void)
306 {
307 return isp16_init();
308 }
309
310 void cleanup_module(void)
311 {
312 release_region(ISP16_IO_BASE, ISP16_IO_SIZE);
313 printk(KERN_INFO "ISP16: module released.\n");
314 }
315 #endif