This source file includes following definitions.
- isp16_detect
- isp16_c928__detect
- isp16_c929__detect
- isp16_cdi_config
- isp16_sound_config
1
2
3
4
5
6
7
8
9
10
11 #define ISP16_DRIVE_X 0x00
12 #define ISP16_SONY 0x02
13 #define ISP16_PANASONIC0 0x02
14 #define ISP16_SANYO0 0x02
15 #define ISP16_MITSUMI 0x04
16 #define ISP16_PANASONIC1 0x06
17 #define ISP16_SANYO1 0x06
18 #define ISP16_DRIVE_NOT_USED 0x08
19 #define ISP16_DRIVE_SET_MASK 0xF1
20
21 #define ISP16_DRIVE_SET_PORT 0xF8D
22
23 #define ISP16_BASE_340 0x00
24 #define ISP16_BASE_330 0x40
25 #define ISP16_BASE_360 0x80
26 #define ISP16_BASE_320 0xC0
27 #define ISP16_IRQ_X 0x00
28 #define ISP16_IRQ_5 0x04
29 #define ISP16_IRQ_7 0x08
30 #define ISP16_IRQ_3 0x0C
31 #define ISP16_IRQ_9 0x10
32 #define ISP16_IRQ_10 0x14
33 #define ISP16_IRQ_11 0x18
34 #define ISP16_DMA_X 0x03
35 #define ISP16_DMA_3 0x00
36 #define ISP16_DMA_5 0x00
37 #define ISP16_DMA_6 0x01
38 #define ISP16_DMA_7 0x02
39 #define ISP16_IO_SET_MASK 0x20
40
41 #define ISP16_IO_SET_PORT 0xF8E
42
43 #define ISP16_C928__ENABLE_PORT 0xF90
44 #define ISP16_C929__ENABLE_PORT 0xF91
45 #define ISP16_ENABLE_CDROM 0x80
46
47
48 #define ISP16_CTRL_PORT 0xF8F
49 #define ISP16_C928__CTRL 0xE2
50 #define ISP16_C929__CTRL 0xE3
51
52 static short isp16_detect(void);
53 static short isp16_c928__detect(void);
54 static short isp16_c929__detect(void);
55 static short isp16_cdi_config( int base, u_char drive_type, int irq, int dma );
56 static void isp16_sound_config( void );
57 static short isp16_type;
58 static u_char isp16_ctrl;
59 static u_short isp16_enable_port;
60
61
62 static u_char special_mask = 0;
63
64 static unsigned char defaults[ 16 ] = {
65 0xA8, 0xA8, 0x18, 0x18, 0x18, 0x18, 0x8E, 0x8E,
66 0x03, 0x00, 0x02, 0x00, 0x0A, 0x00, 0x00, 0x00
67 };
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92 #define ISP16_IN(p) (outb(isp16_ctrl,ISP16_CTRL_PORT), inb(p))
93 #define ISP16_OUT(p,b) (outb(isp16_ctrl,ISP16_CTRL_PORT), outb(b,p))
94
95 static short
96 isp16_detect(void)
97 {
98
99 if ( !( isp16_c929__detect() < 0 ) )
100 return(2);
101 else
102 return( isp16_c928__detect() );
103 }
104
105 static short
106 isp16_c928__detect(void)
107 {
108 u_char ctrl;
109 u_char enable_cdrom;
110 u_char io;
111 short i = -1;
112
113 isp16_ctrl = ISP16_C928__CTRL;
114 isp16_enable_port = ISP16_C928__ENABLE_PORT;
115
116
117
118
119 ctrl = ISP16_IN( ISP16_CTRL_PORT ) & 0xFC;
120 ISP16_OUT( ISP16_CTRL_PORT, ctrl );
121
122
123 enable_cdrom = ISP16_IN( ISP16_C928__ENABLE_PORT ) & 0x38;
124
125 if ( !(enable_cdrom & 0x20) ) {
126
127 io = ISP16_IN( ISP16_IO_SET_PORT ) & 0x03;
128 if ( ((io&0x01)<<1) == (io&0x02) ) {
129 if ( io == 0 ) {
130 i = 0;
131 enable_cdrom |= 0x20;
132 }
133 else {
134 i = 1;
135 enable_cdrom |= 0x28;
136 }
137 ISP16_OUT( ISP16_C928__ENABLE_PORT, enable_cdrom );
138 }
139 else {
140 ISP16_OUT( ISP16_CTRL_PORT, ctrl );
141 return(i);
142 }
143 }
144 else if ( enable_cdrom == 0x20 )
145 i = 0;
146 else if ( enable_cdrom == 0x28 )
147 i = 1;
148
149 ISP16_OUT( ISP16_CTRL_PORT, ctrl );
150
151 return(i);
152 }
153
154 static short
155 isp16_c929__detect(void)
156 {
157 u_char ctrl;
158 u_char tmp;
159
160 isp16_ctrl = ISP16_C929__CTRL;
161 isp16_enable_port = ISP16_C929__ENABLE_PORT;
162
163
164
165
166 ctrl = ISP16_IN( ISP16_CTRL_PORT );
167
168
169 ISP16_OUT( ISP16_CTRL_PORT, 0 );
170 tmp = ISP16_IN( ISP16_CTRL_PORT );
171
172 if ( tmp != 2 )
173 return(-1);
174
175
176 ISP16_OUT( ISP16_CTRL_PORT, ctrl );
177
178 return(2);
179 }
180
181 static short
182 isp16_cdi_config( int base, u_char drive_type, int irq, int dma )
183 {
184 u_char base_code;
185 u_char irq_code;
186 u_char dma_code;
187 u_char i;
188
189 if ( (drive_type == ISP16_MITSUMI) && (dma != 0) )
190 printk( "Mitsumi cdrom drive has no dma support.\n" );
191
192 switch (base) {
193 case 0x340: base_code = ISP16_BASE_340; break;
194 case 0x330: base_code = ISP16_BASE_330; break;
195 case 0x360: base_code = ISP16_BASE_360; break;
196 case 0x320: base_code = ISP16_BASE_320; break;
197 default:
198 printk( "Base address 0x%03X not supported by cdrom interface on ISP16.\n", base );
199 return(-1);
200 }
201 switch (irq) {
202 case 0: irq_code = ISP16_IRQ_X; break;
203 case 5: irq_code = ISP16_IRQ_5;
204 printk( "Irq 5 shouldn't be used by cdrom interface on ISP16,"
205 " due to possible conflicts with the soundcard.\n");
206 break;
207 case 7: irq_code = ISP16_IRQ_7;
208 printk( "Irq 7 shouldn't be used by cdrom interface on ISP16,"
209 " due to possible conflicts with the soundcard.\n");
210 break;
211 case 3: irq_code = ISP16_IRQ_3; break;
212 case 9: irq_code = ISP16_IRQ_9; break;
213 case 10: irq_code = ISP16_IRQ_10; break;
214 case 11: irq_code = ISP16_IRQ_11; break;
215 default:
216 printk( "Irq %d not supported by cdrom interface on ISP16.\n", irq );
217 return(-1);
218 }
219 switch (dma) {
220 case 0: dma_code = ISP16_DMA_X; break;
221 case 1: printk( "Dma 1 cannot be used by cdrom interface on ISP16,"
222 " due to conflict with the soundcard.\n");
223 return(-1); break;
224 case 3: dma_code = ISP16_DMA_3; break;
225 case 5: dma_code = ISP16_DMA_5; break;
226 case 6: dma_code = ISP16_DMA_6; break;
227 case 7: dma_code = ISP16_DMA_7; break;
228 default:
229 printk( "Dma %d not supported by cdrom interface on ISP16.\n", dma );
230 return(-1);
231 }
232
233 if ( drive_type != ISP16_SONY && drive_type != ISP16_PANASONIC0 &&
234 drive_type != ISP16_PANASONIC1 && drive_type != ISP16_SANYO0 &&
235 drive_type != ISP16_SANYO1 && drive_type != ISP16_MITSUMI &&
236 drive_type != ISP16_DRIVE_X ) {
237 printk( "Drive type (code 0x%02X) not supported by cdrom"
238 " interface on ISP16.\n", drive_type );
239 return(-1);
240 }
241
242
243 i = ISP16_IN(ISP16_DRIVE_SET_PORT) & ISP16_DRIVE_SET_MASK;
244 ISP16_OUT( ISP16_DRIVE_SET_PORT, i|drive_type );
245
246
247 if ( isp16_type > 1 )
248 ISP16_OUT( isp16_enable_port, ISP16_ENABLE_CDROM );
249
250
251 i = ISP16_IN(ISP16_IO_SET_PORT) & ISP16_IO_SET_MASK;
252 ISP16_OUT( ISP16_IO_SET_PORT, i|base_code|irq_code|dma_code );
253
254 return(0);
255 }
256
257 static void isp16_sound_config( void )
258 {
259 int i;
260 u_char saved;
261
262 saved = ISP16_IN( 0xF8D ) & 0x8F;
263
264 ISP16_OUT( 0xF8D, 0x40 );
265
266
267
268
269 for( i = 16*1024; i--; );
270
271 ISP16_OUT( 0xF8D, saved );
272
273 ISP16_OUT( 0xF91, 0x1B );
274
275 for( i = 5*64*1024; i != 0; i-- )
276 if( !( inb( 0x534 ) & 0x80 ) ) break;
277
278 if( i > 0 ) {
279 saved = ( inb( 0x534 ) & 0xE0 ) | 0x0A;
280 outb( saved, 0x534 );
281
282 special_mask = ( inb( 0x535 ) >> 4 ) & 0x08;
283
284 saved = ( inb( 0x534 ) & 0xE0 ) | 0x0C;
285 outb( saved, 0x534 );
286
287 switch( inb( 0x535 ) ) {
288 case 0x09:
289 case 0x0A:
290 special_mask |= 0x05;
291 break;
292 case 0x8A:
293 special_mask = 0x0F;
294 break;
295 default:
296 i = 0;
297 }
298 }
299 if ( i == 0 ) {
300 printk( "Strange MediaMagic, but\n" );
301 }
302 else {
303 printk( "Conf:" );
304 saved = inb( 0x534 ) & 0xE0;
305 for( i = 0; i < 16; i++ ) {
306 outb( 0x20 | ( u_char )i, 0x534 );
307 outb( defaults[i], 0x535 );
308 }
309 for ( i = 0; i < 16; i++ ) {
310 outb( 0x20 | ( u_char )i, 0x534 );
311 saved = inb( 0x535 );
312 printk( " %02X", saved );
313 }
314 printk( "\n" );
315 }
316
317 ISP16_OUT( 0xF91, 0xA0 | special_mask );
318
319
320
321
322 ISP16_OUT( 0xF90, 0xA2 );
323 ISP16_OUT( 0xF92, 0x03 );
324
325
326
327
328 ISP16_OUT( 0xF93, 0x0A );
329
330
331
332
333
334
335
336
337 }