~ubuntu-branches/ubuntu/gutsy/vnc4/gutsy

« back to all changes in this revision

Viewing changes to unix/xc/programs/Xserver/hw/xfree86/drivers/nsc/panel/drac9210.c

  • Committer: Bazaar Package Importer
  • Author(s): Ola Lundqvist
  • Date: 2006-05-15 20:35:17 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060515203517-l4lre1ku942mn26k
Tags: 4.1.1+X4.3.0-10
* Correction of critical security issue. Thanks to Martin Kogler
  <e9925248@student.tuwien.ac.at> that informed me about the issue,
  and provided the patch.
  This flaw was originally found by Steve Wiseman of intelliadmin.com.
* Applied patch from Javier Kohen <jkohen@users.sourceforge.net> that
  inform the user that only 8 first characters of the password will
  actually be used when typing more than 8 characters, closes:
  #355619.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nsc/panel/drac9210.c,v 1.2 2003/01/14 09:34:35 alanh Exp $ */
 
2
/*
 
3
 * $Workfile: drac9210.c $
 
4
 * $Revision: 5 $
 
5
 *
 
6
 * File Contents: This file contains the panel library files to the 
 
7
 *                platforms with 9210, and 9211 support.
 
8
 *
 
9
 * SubModule:     Geode FlatPanel library
 
10
 *
 
11
 */
 
12
 
 
13
/* 
 
14
 * NSC_LIC_ALTERNATIVE_PREAMBLE
 
15
 *
 
16
 * Revision 1.0
 
17
 *
 
18
 * National Semiconductor Alternative GPL-BSD License
 
19
 *
 
20
 * National Semiconductor Corporation licenses this software 
 
21
 * ("Software"):
 
22
 *
 
23
 * Panel Library
 
24
 *
 
25
 * under one of the two following licenses, depending on how the 
 
26
 * Software is received by the Licensee.
 
27
 * 
 
28
 * If this Software is received as part of the Linux Framebuffer or
 
29
 * other GPL licensed software, then the GPL license designated 
 
30
 * NSC_LIC_GPL applies to this Software; in all other circumstances 
 
31
 * then the BSD-style license designated NSC_LIC_BSD shall apply.
 
32
 *
 
33
 * END_NSC_LIC_ALTERNATIVE_PREAMBLE */
 
34
 
 
35
/* NSC_LIC_BSD
 
36
 *
 
37
 * National Semiconductor Corporation Open Source License for 
 
38
 *
 
39
 * Panel Library
 
40
 *
 
41
 * (BSD License with Export Notice)
 
42
 *
 
43
 * Copyright (c) 1999-2001
 
44
 * National Semiconductor Corporation.
 
45
 * All rights reserved.
 
46
 *
 
47
 * Redistribution and use in source and binary forms, with or without 
 
48
 * modification, are permitted provided that the following conditions 
 
49
 * are met: 
 
50
 *
 
51
 *   * Redistributions of source code must retain the above copyright 
 
52
 *     notice, this list of conditions and the following disclaimer. 
 
53
 *
 
54
 *   * Redistributions in binary form must reproduce the above 
 
55
 *     copyright notice, this list of conditions and the following 
 
56
 *     disclaimer in the documentation and/or other materials provided 
 
57
 *     with the distribution. 
 
58
 *
 
59
 *   * Neither the name of the National Semiconductor Corporation nor 
 
60
 *     the names of its contributors may be used to endorse or promote 
 
61
 *     products derived from this software without specific prior 
 
62
 *     written permission. 
 
63
 * 
 
64
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
 
65
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
 
66
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
 
67
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
 
68
 * NATIONAL SEMICONDUCTOR CORPORATION OR CONTRIBUTORS BE LIABLE FOR ANY 
 
69
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
 
70
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 
 
71
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
 
72
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 
 
73
 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE,
 
74
 * INTELLECTUAL PROPERTY INFRINGEMENT, OR OTHERWISE) ARISING IN ANY WAY 
 
75
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
 
76
 * OF SUCH DAMAGE.
 
77
 *
 
78
 * EXPORT LAWS: THIS LICENSE ADDS NO RESTRICTIONS TO THE EXPORT LAWS OF 
 
79
 * YOUR JURISDICTION. It is licensee's responsibility to comply with 
 
80
 * any export regulations applicable in licensee's jurisdiction. Under 
 
81
 * CURRENT (2001) U.S. export regulations this software 
 
82
 * is eligible for export from the U.S. and can be downloaded by or 
 
83
 * otherwise exported or reexported worldwide EXCEPT to U.S. embargoed 
 
84
 * destinations which include Cuba, Iraq, Libya, North Korea, Iran, 
 
85
 * Syria, Sudan, Afghanistan and any other country to which the U.S. 
 
86
 * has embargoed goods and services. 
 
87
 *
 
88
 * END_NSC_LIC_BSD */
 
89
 
 
90
/* NSC_LIC_GPL
 
91
 *
 
92
 * National Semiconductor Corporation Gnu General Public License for 
 
93
 *
 
94
 * Panel Library
 
95
 *
 
96
 * (GPL License with Export Notice)
 
97
 *
 
98
 * Copyright (c) 1999-2001
 
99
 * National Semiconductor Corporation.
 
100
 * All rights reserved.
 
101
 *
 
102
 * Redistribution and use in source and binary forms, with or without 
 
103
 * modification, are permitted under the terms of the GNU General 
 
104
 * Public License as published by the Free Software Foundation; either 
 
105
 * version 2 of the License, or (at your option) any later version  
 
106
 *
 
107
 * In addition to the terms of the GNU General Public License, neither 
 
108
 * the name of the National Semiconductor Corporation nor the names of 
 
109
 * its contributors may be used to endorse or promote products derived 
 
110
 * from this software without specific prior written permission. 
 
111
 *
 
112
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
 
113
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
 
114
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
 
115
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
 
116
 * NATIONAL SEMICONDUCTOR CORPORATION OR CONTRIBUTORS BE LIABLE FOR ANY 
 
117
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
 
118
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 
 
119
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
 
120
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 
 
121
 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE, 
 
122
 * INTELLECTUAL PROPERTY INFRINGEMENT, OR OTHERWISE) ARISING IN ANY WAY 
 
123
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
 
124
 * OF SUCH DAMAGE. See the GNU General Public License for more details. 
 
125
 *
 
126
 * EXPORT LAWS: THIS LICENSE ADDS NO RESTRICTIONS TO THE EXPORT LAWS OF 
 
127
 * YOUR JURISDICTION. It is licensee's responsibility to comply with 
 
128
 * any export regulations applicable in licensee's jurisdiction. Under 
 
129
 * CURRENT (2001) U.S. export regulations this software 
 
130
 * is eligible for export from the U.S. and can be downloaded by or 
 
131
 * otherwise exported or reexported worldwide EXCEPT to U.S. embargoed 
 
132
 * destinations which include Cuba, Iraq, Libya, North Korea, Iran, 
 
133
 * Syria, Sudan, Afghanistan and any other country to which the U.S. 
 
134
 * has embargoed goods and services. 
 
135
 *
 
136
 * You should have received a copy of the GNU General Public License 
 
137
 * along with this file; if not, write to the Free Software Foundation, 
 
138
 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
 
139
 *
 
140
 * END_NSC_LIC_GPL */
 
141
 
 
142
#include "drac9210.h"
 
143
 
 
144
#define CS9210                  0x40    /* Chip select pin */
 
145
 
 
146
/* 9210 on Draco */
 
147
#define CLOCK9210               0x04    /* Clock pin */
 
148
#define DATAIN9210              0x20    /* Data from 9210 */
 
149
#define DATAOUT9210             0x80    /* Data to 9210 */
 
150
 
 
151
static void DracoWriteData(unsigned char data);
 
152
static void DracoReadData(unsigned char *data);
 
153
static void Draco9210GpioInit();
 
154
static void Draco9210SetCS(void);
 
155
static unsigned char Draco9210ReadReg(unsigned char index);
 
156
static void Draco9210WriteReg(unsigned char index, unsigned char data);
 
157
static void Draco9210ClearCS(void);
 
158
static void Draco9210SetDataOut(void);
 
159
static void Draco9210ClearDataOut(void);
 
160
static unsigned char Draco9210ReadDataIn(void);
 
161
static void Draco9210ToggleClock(void);
 
162
 
 
163
void
 
164
Draco9210Init(Pnl_PanelStat * pstat)
 
165
{
 
166
   unsigned char panelvalues[] = {
 
167
      0x2, 0x80,
 
168
      0x2, 0x24,
 
169
      0x03, 0x00,
 
170
      0xc0, 0x00,
 
171
      0xc1, 0x00,
 
172
      0xc2, 0x00,
 
173
      0xc3, 0x00,
 
174
      0xc4, 0x00,
 
175
      0xc5, 0x01,
 
176
      0xc6, 0xff,
 
177
      0xc7, 0xff,
 
178
      0xc8, 0x3,
 
179
      0xc9, 0xfe,
 
180
      0xca, 0x0,
 
181
      0xcb, 0x3f,
 
182
      0xcc, 0xc,
 
183
      0xcd, 0x1,
 
184
      0xce, 0xff,
 
185
      0xcf, 0xc1,
 
186
      0xd0, 0x0,
 
187
      0xd1, 0x7e,
 
188
      0xd2, 0x3,
 
189
      0xd3, 0xfe,
 
190
      0xd4, 0x3,
 
191
      0xd5, 0x81,
 
192
      0xd6, 0xfc,
 
193
      0xd7, 0x3f,
 
194
      0xd8, 0x14,
 
195
      0xd9, 0x1e,
 
196
      0xda, 0x0f,
 
197
      0xdb, 0xc7,
 
198
      0xdc, 0x29,
 
199
      0xdd, 0xe1,
 
200
      0xde, 0xf1,
 
201
      0xdf, 0xf9,
 
202
      0xe0, 0x2,
 
203
      0xe1, 0xe,
 
204
      0xe2, 0x1e,
 
205
      0xe3, 0x3e,
 
206
      0xe4, 0x04,
 
207
      0xe5, 0x71,
 
208
      0xe6, 0xe3,
 
209
      0xe7, 0xcf,
 
210
      0xe8, 0x1,
 
211
      0xe9, 0x86,
 
212
      0xea, 0x3c,
 
213
      0xeb, 0xf3,
 
214
      0xec, 0xa,
 
215
      0xed, 0x39,
 
216
      0xee, 0xc7,
 
217
      0xef, 0x3d,
 
218
 
 
219
      0xf0, 0x14,
 
220
      0xf1, 0xc6,
 
221
      0xf2, 0x39,
 
222
      0xf3, 0xce,
 
223
      0xf4, 0x3,
 
224
      0xf5, 0x19,
 
225
      0xf6, 0xce,
 
226
      0xf7, 0x77,
 
227
      0xf8, 0x0,
 
228
      0xf9, 0x66,
 
229
      0xfa, 0x33,
 
230
      0xfb, 0xbb,
 
231
      0xfc, 0x2d,
 
232
      0xfd, 0x99,
 
233
      0xfe, 0xdd,
 
234
      0xff, 0xdd,
 
235
 
 
236
      0x3, 0x1,
 
237
      0xc0, 0x2,
 
238
      0xc1, 0x22,
 
239
      0xc2, 0x66,
 
240
      0xc3, 0x66,
 
241
      0xc4, 0x0,
 
242
      0xc5, 0xcd,
 
243
      0xc6, 0x99,
 
244
      0xc7, 0xbb,
 
245
      0xc8, 0x5,
 
246
      0xc9, 0x32,
 
247
      0xca, 0x66,
 
248
      0xcb, 0xdd,
 
249
      0xcc, 0x1a,
 
250
      0xcd, 0x4d,
 
251
      0xce, 0x9b,
 
252
      0xcf, 0x6f,
 
253
      0xd0, 0x0,
 
254
      0xd1, 0x92,
 
255
      0xd2, 0x6d,
 
256
      0xd3, 0xb6,
 
257
      0xd4, 0x5,
 
258
      0xd5, 0x25,
 
259
      0xd6, 0xb6,
 
260
      0xd7, 0xdb,
 
261
      0xd8, 0x2,
 
262
      0xd9, 0x5a,
 
263
      0xda, 0x4b,
 
264
      0xdb, 0x6d,
 
265
      0xdc, 0x29,
 
266
      0xdd, 0xa5,
 
267
      0xde, 0xb5,
 
268
      0xdf, 0xb7,
 
269
      0xe0, 0x4,
 
270
      0xe1, 0x4a,
 
271
      0xe2, 0x5a,
 
272
      0xe3, 0xda,
 
273
      0xe4, 0x12,
 
274
      0xe5, 0x95,
 
275
      0xe6, 0xad,
 
276
      0xe7, 0x6f,
 
277
      0xe8, 0x1,
 
278
      0xe9, 0x2a,
 
279
      0xea, 0x56,
 
280
      0xeb, 0xb5,
 
281
      0xec, 0xe,
 
282
      0xed, 0x55,
 
283
      0xee, 0xab,
 
284
      0xef, 0x5f,
 
285
      0xf0, 0x0,
 
286
      0xf1, 0xaa,
 
287
      0xf2, 0x55,
 
288
      0xf3, 0xea,
 
289
      0xf4, 0x1,
 
290
      0xf5, 0x55,
 
291
      0xf6, 0xaa,
 
292
      0xf7, 0xbf,
 
293
      0xf8, 0x6,
 
294
      0xf9, 0xaa,
 
295
      0xfa, 0x55,
 
296
      0xfb, 0x55,
 
297
      0xfc, 0x39,
 
298
      0xfd, 0x55,
 
299
      0xfe, 0xff,
 
300
      0xff, 0xff,
 
301
 
 
302
      0x3, 0x2,
 
303
      0xc0, 0x0,
 
304
      0xc1, 0x0,
 
305
      0xc2, 0xaa,
 
306
      0xc3, 0xaa,
 
307
      0xc4, 0x6,
 
308
      0xc5, 0xab,
 
309
      0xc6, 0x55,
 
310
      0xc7, 0x55,
 
311
      0xc8, 0x01,
 
312
      0xc9, 0x54,
 
313
      0xca, 0xaa,
 
314
      0xcb, 0xbf,
 
315
      0xcc, 0x8,
 
316
      0xcd, 0xab,
 
317
      0xce, 0x55,
 
318
      0xcf, 0xeb,
 
319
      0xd0, 0x6,
 
320
      0xd1, 0x54,
 
321
      0xd2, 0xab,
 
322
      0xd3, 0x5e,
 
323
      0xd4, 0x1,
 
324
      0xd5, 0x2b,
 
325
      0xd6, 0x56,
 
326
      0xd7, 0xb5,
 
327
      0xd8, 0x12,
 
328
      0xd9, 0x94,
 
329
      0xda, 0xad,
 
330
      0xdb, 0x6f,
 
331
      0xdc, 0x2d,
 
332
      0xdd, 0x4b,
 
333
      0xde, 0x5b,
 
334
      0xdf, 0xdb,
 
335
      0xe0, 0x0,
 
336
      0xe1, 0xa4,
 
337
      0xe2, 0xb4,
 
338
      0xe3, 0xb6,
 
339
      0xe4, 0x2,
 
340
      0xe5, 0x5b,
 
341
      0xe6, 0x4b,
 
342
      0xe7, 0x6d,
 
343
      0xe8, 0x5,
 
344
      0xe9, 0x24,
 
345
      0xea, 0xb6,
 
346
      0xeb, 0xdb,
 
347
      0xec, 0x8,
 
348
      0xed, 0x93,
 
349
      0xee, 0x6d,
 
350
      0xef, 0xb7,
 
351
      0xf0, 0x12,
 
352
      0xf1, 0x4c,
 
353
      0xf2, 0x9b,
 
354
      0xf3, 0x6e,
 
355
      0xf4, 0x5,
 
356
      0xf5, 0x33,
 
357
      0xf6, 0x66,
 
358
      0xf7, 0xdd,
 
359
      0xf8, 0x0,
 
360
      0xf9, 0xcc,
 
361
      0xfa, 0x99,
 
362
      0xfb, 0xbb,
 
363
      0xfc, 0x2b,
 
364
      0xfd, 0x33,
 
365
      0xfe, 0x77,
 
366
      0xff, 0x77,
 
367
 
 
368
      0x3, 0x3,
 
369
      0xc0, 0x4,
 
370
      0xc1, 0x88,
 
371
      0xc2, 0xcc,
 
372
      0xc3, 0xcc,
 
373
      0xc4, 0x0,
 
374
      0xc5, 0x67,
 
375
      0xc6, 0x33,
 
376
      0xc7, 0xbb,
 
377
      0xc8, 0x3,
 
378
      0xc9, 0x18,
 
379
      0xca, 0xce,
 
380
      0xcb, 0x77,
 
381
      0xcc, 0x1c,
 
382
      0xcd, 0xc7,
 
383
      0xce, 0x39,
 
384
      0xcf, 0xcf,
 
385
 
 
386
      0xd0, 0x2,
 
387
      0xd1, 0x38,
 
388
      0xd2, 0xc7,
 
389
      0xd3, 0x3c,
 
390
      0xd4, 0x1,
 
391
      0xd5, 0x87,
 
392
      0xd6, 0x3c,
 
393
      0xd7, 0xf3,
 
394
      0xd8, 0x4,
 
395
      0xd9, 0x70,
 
396
      0xda, 0xe3,
 
397
      0xdb, 0xcf,
 
398
      0xdc, 0x2b,
 
399
      0xdd, 0xf,
 
400
      0xde, 0x1f,
 
401
      0xdf, 0x3f,
 
402
      0xe0, 0x00,
 
403
      0xe1, 0xe0,
 
404
      0xe2, 0xf0,
 
405
      0xe3, 0xf8,
 
406
      0xe4, 0x14,
 
407
      0xe5, 0x1f,
 
408
      0xe6, 0xf,
 
409
      0xe7, 0xc7,
 
410
      0xe8, 0x3,
 
411
      0xe9, 0x80,
 
412
      0xea, 0xfc,
 
413
      0xeb, 0x3f,
 
414
      0xec, 0x8,
 
415
      0xed, 0x7f,
 
416
      0xee, 0x3,
 
417
      0xef, 0xff,
 
418
      0xf0, 0x4,
 
419
      0xf1, 0x0,
 
420
      0xf2, 0xff,
 
421
      0xf3, 0xc0,
 
422
      0xf4, 0x3,
 
423
      0xf5, 0xff,
 
424
      0xf6, 0x0,
 
425
      0xf7, 0x3f,
 
426
      0xf8, 0x0,
 
427
      0xf9, 0x0,
 
428
      0xfa, 0xff,
 
429
      0xfb, 0xff,
 
430
      0xfc, 0x3f,
 
431
      0xfd, 0xff,
 
432
      0xfe, 0xff,
 
433
      0xff, 0xff,
 
434
      0x3, 0x4,
 
435
 
 
436
      /* Setup the Diter to Pattern33 */
 
437
      0x80, 0xdd,
 
438
      0x81, 0xdd,
 
439
      0x82, 0x33,
 
440
      0x83, 0x33,
 
441
      0x84, 0xdd,
 
442
      0x85, 0xdd,
 
443
      0x86, 0x33,
 
444
      0x87, 0x33,
 
445
      0x88, 0x33,
 
446
      0x89, 0x33,
 
447
      0x8a, 0x77,
 
448
      0x8b, 0x77,
 
449
      0x8c, 0x33,
 
450
      0x8d, 0x33,
 
451
      0x8e, 0x77,
 
452
      0x8f, 0x77,
 
453
      0x90, 0xdd,
 
454
      0x91, 0xdd,
 
455
      0x92, 0x33,
 
456
      0x93, 0x33,
 
457
      0x94, 0xdd,
 
458
      0x95, 0xdd,
 
459
      0x96, 0x33,
 
460
      0x97, 0x33,
 
461
      0x98, 0x33,
 
462
      0x99, 0x33,
 
463
      0x9a, 0x77,
 
464
      0x9b, 0x77,
 
465
      0x9c, 0x33,
 
466
      0x9d, 0x33,
 
467
      0x9e, 0x77,
 
468
      0x9f, 0x77,
 
469
 
 
470
      0x4, 0x20,
 
471
      0x5, 0x3,
 
472
      0x6, 0x56,
 
473
      0x7, 0x2,
 
474
      0x8, 0x1c,
 
475
      0x9, 0x0,
 
476
      0xa, 0x26,
 
477
      0xb, 0x0,
 
478
      0xc, 0x15,
 
479
      0xd, 0x4,
 
480
      0xe, 0x50,
 
481
      0xf, 0x4,
 
482
      0x10, 0xfa,
 
483
      0x11, 0x0,
 
484
      0x12, 0xc8,
 
485
      0x13, 0x0,
 
486
      0x14, 0x31,
 
487
      0x15, 0x23,
 
488
      0x16, 0x0,
 
489
 
 
490
      /* Enable DSTN panel */
 
491
      0x2, 0x64
 
492
   };
 
493
   unsigned char index, data;
 
494
   int i;
 
495
 
 
496
   gfx_delay_milliseconds(100);
 
497
   Draco9210GpioInit();
 
498
   Draco9210SetCS();
 
499
   Draco9210ToggleClock();
 
500
   Draco9210ToggleClock();
 
501
   Draco9210ToggleClock();
 
502
   Draco9210ToggleClock();
 
503
   Draco9210ClearCS();
 
504
 
 
505
#if defined(_WIN32)                     /* For Windows */
 
506
   for (i = 0; i < 10; i++) {
 
507
      _asm {
 
508
      out 0EDh, al}
 
509
   }
 
510
 
 
511
#elif defined(linux)                    /* Linux */
 
512
 
 
513
#endif
 
514
 
 
515
   for (i = 0; i < 630; i += 2) {
 
516
      index = panelvalues[i];
 
517
      data = panelvalues[i + 1];
 
518
      Draco9210WriteReg(index, data);
 
519
   }
 
520
 
 
521
}
 
522
 
 
523
static void
 
524
DracoWriteData(unsigned char data)
 
525
{
 
526
   int i;
 
527
   unsigned char mask = 0x80, databit;
 
528
 
 
529
   for (i = 0; i < 8; i++) {
 
530
 
 
531
      databit = data & mask;
 
532
      if (data & mask) {
 
533
         Draco9210SetDataOut();
 
534
      } else {
 
535
         Draco9210ClearDataOut();
 
536
      }
 
537
      mask >>= 1;
 
538
      Draco9210ToggleClock();
 
539
   }
 
540
}
 
541
 
 
542
static void
 
543
DracoReadData(unsigned char *data)
 
544
{
 
545
   int i;
 
546
   unsigned char tmp = 0, readbit;
 
547
 
 
548
   Draco9210ClearDataOut();
 
549
   Draco9210ToggleClock();
 
550
   for (i = 0; i < 7; i++) {
 
551
      readbit = Draco9210ReadDataIn();
 
552
      tmp |= (readbit & 0x1);
 
553
      tmp <<= 1;
 
554
      Draco9210ToggleClock();
 
555
   }
 
556
   readbit = Draco9210ReadDataIn();
 
557
   tmp |= (readbit & 0x1);
 
558
   *data = tmp;
 
559
}
 
560
 
 
561
#if defined(_WIN32)                     /* For Windows */
 
562
 
 
563
void
 
564
Draco9210GpioInit()
 
565
{
 
566
   _asm {
 
567
      pushf 
 
568
      cli
 
569
          mov dx, 0CF8h
 
570
          mov eax, CX55x0_ID + 090h
 
571
          out dx, eax
 
572
          mov dx, 0CFCh 
 
573
          mov al, 0CFh 
 
574
          mov ah, 00h 
 
575
          out dx, ax 
 
576
          popf
 
577
   }
 
578
}
 
579
 
 
580
void
 
581
Draco9210SetCS()
 
582
{
 
583
   _asm {
 
584
      pushf
 
585
      ;Point to PCI address register
 
586
      mov dx, 0CF8h
 
587
      ;55 XX GPIO data register 
 
588
      mov eax, CX55x0_ID + 090h
 
589
      out dx, eax
 
590
      ;Point to PCI data register (CFCh)
 
591
      mov dx, 0CFCh
 
592
 
 
593
      in ax, dx
 
594
      and ah, 30h
 
595
      mov ah, c92DataReg
 
596
      or ah, CS9210
 
597
      mov c92DataReg, ah
 
598
      out dx, ax
 
599
      popf
 
600
   }
 
601
}
 
602
 
 
603
void
 
604
Draco9210ClearCS()
 
605
{
 
606
   _asm {
 
607
      pushf
 
608
      ;Point to PCI address register
 
609
      mov dx, 0CF8h
 
610
      ;55 XX GPIO data register 
 
611
      mov eax, CX55x0_ID + 090h
 
612
      out dx, eax
 
613
      ;Point to PCI data register (CFCh)
 
614
      mov dx, 0CFCh
 
615
      ;Set CS LOW
 
616
      in ax, dx
 
617
      mov ah, c92DataReg
 
618
      and ah, NOT CS9210
 
619
      mov c92DataReg, ah
 
620
      out dx, ax
 
621
      popf
 
622
   }
 
623
}
 
624
 
 
625
void
 
626
Draco9210SetDataOut()
 
627
{
 
628
   _asm {
 
629
      pushf
 
630
      ;Point to PCI address register
 
631
      mov dx, 0CF8h
 
632
      ;55 XX GPIO data register 
 
633
      mov eax, CX55x0_ID + 090h
 
634
      out dx, eax
 
635
      ;Point to PCI data register (CFCh)
 
636
      mov dx, 0CFCh
 
637
      ;Set DATA HIGH
 
638
      in ax, dx
 
639
      mov ah, c92DataReg
 
640
      or ah, DATAOUT9210
 
641
      mov c92DataReg, ah
 
642
      out dx, ax
 
643
      popf
 
644
   }
 
645
}
 
646
 
 
647
void
 
648
Draco9210ClearDataOut()
 
649
{
 
650
   _asm {
 
651
      pushf
 
652
      ;Point to PCI address register
 
653
      mov dx, 0CF8h
 
654
      mov eax, CX55x0_ID + 090h;
 
655
      ;55 XX GPIO data register
 
656
      out dx, eax
 
657
      ;Point to PCI data register (CFCh)
 
658
      mov dx, 0CFCh
 
659
      ;Set Data LOW
 
660
      in ax, dx
 
661
      mov ah, c92DataReg
 
662
      and ah, NOT DATAOUT9210
 
663
      mov c92DataReg, ah
 
664
      out dx, ax
 
665
      popf
 
666
   }
 
667
}
 
668
 
 
669
unsigned char
 
670
Draco9210ReadDataIn()
 
671
{
 
672
   unsigned char readdata;
 
673
 
 
674
   _asm {
 
675
      pushf 
 
676
      ;Point to PCI address register 
 
677
      mov dx, 0CF8h
 
678
      ;55 XX GPIO data register 
 
679
      mov eax, CX55x0_ID + 090h
 
680
      out dx, eax 
 
681
      ;Point to PCI data register (CFCh)
 
682
      mov dx, 0FCh
 
683
 
 
684
      in ax, dx
 
685
      ;Preserve just Data IN bit
 
686
      and ah, DATAIN9210
 
687
      mov al, ah
 
688
      cmp al, 0
 
689
      ;Is it LOW ? 
 
690
      je readDataLow 
 
691
      ;must be HIGH
 
692
      mov al, 1
 
693
   readDataLow:
 
694
      mov readdata, al
 
695
      popf
 
696
   }
 
697
   return (readdata);
 
698
}
 
699
 
 
700
void
 
701
Draco9210ToggleClock()
 
702
{
 
703
   _asm {
 
704
      pushf
 
705
      ;Point to PCI address register
 
706
      mov dx, 0CF8h
 
707
      ;55 XX GPIO data register 
 
708
      mov eax, CX55x0_ID + 090h
 
709
      ;Point to PCI data register (CFCh)
 
710
      out dx, eax 
 
711
      mov dx, 0CFCh
 
712
      ;SET CLOCK 
 
713
      in ax, dx 
 
714
      mov ah, c92DataReg 
 
715
      or ah, CLOCK9210 
 
716
      mov c92DataReg, ah 
 
717
      out dx, ax 
 
718
      out 0EDh, al      /*      IOPAUSE */
 
719
      ;Point to PCI address register 
 
720
      mov dx, 0CF8h
 
721
      ;55 XX GPIO data register
 
722
      mov eax, CX55x0_ID + 090h
 
723
      out dx, eax
 
724
      ;Point to PCI data register (CFCh)
 
725
      mov dx, 0CFCh;
 
726
      ;CLEAR CLOCK
 
727
      in ax, dx
 
728
      mov ah, c92DataReg
 
729
      and ah, NOT CLOCK9210 
 
730
      mov c92DataReg, ah 
 
731
      out dx, ax 
 
732
      popf
 
733
   }
 
734
}
 
735
 
 
736
#elif defined(linux)                    /* Linux */
 
737
 
 
738
void
 
739
Draco9210GpioInit()
 
740
{
 
741
}
 
742
void
 
743
Draco9210SetCS()
 
744
{
 
745
}
 
746
void
 
747
Draco9210ClearCS()
 
748
{
 
749
}
 
750
void
 
751
Draco9210SetDataOut()
 
752
{
 
753
}
 
754
void
 
755
Draco9210ClearDataOut()
 
756
{
 
757
}
 
758
unsigned char
 
759
Draco9210ReadDataIn()
 
760
{
 
761
}
 
762
void
 
763
Draco9210ToggleClock()
 
764
{
 
765
}
 
766
 
 
767
#endif
 
768
 
 
769
unsigned char
 
770
Draco9210ReadReg(unsigned char index)
 
771
{
 
772
   unsigned char data;
 
773
 
 
774
   Draco9210SetCS();
 
775
   Draco9210ToggleClock();
 
776
   Draco9210SetDataOut();
 
777
   Draco9210ToggleClock();
 
778
   Draco9210ClearDataOut();
 
779
   Draco9210ToggleClock();
 
780
   Draco9210ClearDataOut();
 
781
   Draco9210ToggleClock();
 
782
   Draco9210ClearDataOut();
 
783
   Draco9210ToggleClock();
 
784
 
 
785
   DracoWriteData(index);
 
786
   DracoReadData(&data);
 
787
 
 
788
   return (data);
 
789
}
 
790
 
 
791
void
 
792
Draco9210WriteReg(unsigned char index, unsigned char data)
 
793
{
 
794
 
 
795
   Draco9210SetCS();
 
796
   Draco9210ToggleClock();
 
797
 
 
798
   Draco9210SetDataOut();
 
799
   Draco9210ToggleClock();
 
800
 
 
801
   Draco9210ClearDataOut();
 
802
   Draco9210ToggleClock();
 
803
 
 
804
   Draco9210ClearDataOut();
 
805
   Draco9210ToggleClock();
 
806
 
 
807
   Draco9210SetDataOut();
 
808
   Draco9210ToggleClock();
 
809
 
 
810
   DracoWriteData(index);
 
811
   DracoWriteData(data);
 
812
 
 
813
   Draco9210ClearDataOut();
 
814
   Draco9210ToggleClock();
 
815
 
 
816
   Draco9210ClearCS();
 
817
   Draco9210ToggleClock();
 
818
   Draco9210ToggleClock();
 
819
 
 
820
}