1
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nsc/panel/drac9210.c,v 1.2 2003/01/14 09:34:35 alanh Exp $ */
3
* $Workfile: drac9210.c $
6
* File Contents: This file contains the panel library files to the
7
* platforms with 9210, and 9211 support.
9
* SubModule: Geode FlatPanel library
14
* NSC_LIC_ALTERNATIVE_PREAMBLE
18
* National Semiconductor Alternative GPL-BSD License
20
* National Semiconductor Corporation licenses this software
25
* under one of the two following licenses, depending on how the
26
* Software is received by the Licensee.
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.
33
* END_NSC_LIC_ALTERNATIVE_PREAMBLE */
37
* National Semiconductor Corporation Open Source License for
41
* (BSD License with Export Notice)
43
* Copyright (c) 1999-2001
44
* National Semiconductor Corporation.
45
* All rights reserved.
47
* Redistribution and use in source and binary forms, with or without
48
* modification, are permitted provided that the following conditions
51
* * Redistributions of source code must retain the above copyright
52
* notice, this list of conditions and the following disclaimer.
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.
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
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
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.
92
* National Semiconductor Corporation Gnu General Public License for
96
* (GPL License with Export Notice)
98
* Copyright (c) 1999-2001
99
* National Semiconductor Corporation.
100
* All rights reserved.
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
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.
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.
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.
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
142
#include "drac9210.h"
144
#define CS9210 0x40 /* Chip select pin */
147
#define CLOCK9210 0x04 /* Clock pin */
148
#define DATAIN9210 0x20 /* Data from 9210 */
149
#define DATAOUT9210 0x80 /* Data to 9210 */
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);
164
Draco9210Init(Pnl_PanelStat * pstat)
166
unsigned char panelvalues[] = {
436
/* Setup the Diter to Pattern33 */
490
/* Enable DSTN panel */
493
unsigned char index, data;
496
gfx_delay_milliseconds(100);
499
Draco9210ToggleClock();
500
Draco9210ToggleClock();
501
Draco9210ToggleClock();
502
Draco9210ToggleClock();
505
#if defined(_WIN32) /* For Windows */
506
for (i = 0; i < 10; i++) {
511
#elif defined(linux) /* Linux */
515
for (i = 0; i < 630; i += 2) {
516
index = panelvalues[i];
517
data = panelvalues[i + 1];
518
Draco9210WriteReg(index, data);
524
DracoWriteData(unsigned char data)
527
unsigned char mask = 0x80, databit;
529
for (i = 0; i < 8; i++) {
531
databit = data & mask;
533
Draco9210SetDataOut();
535
Draco9210ClearDataOut();
538
Draco9210ToggleClock();
543
DracoReadData(unsigned char *data)
546
unsigned char tmp = 0, readbit;
548
Draco9210ClearDataOut();
549
Draco9210ToggleClock();
550
for (i = 0; i < 7; i++) {
551
readbit = Draco9210ReadDataIn();
552
tmp |= (readbit & 0x1);
554
Draco9210ToggleClock();
556
readbit = Draco9210ReadDataIn();
557
tmp |= (readbit & 0x1);
561
#if defined(_WIN32) /* For Windows */
570
mov eax, CX55x0_ID + 090h
585
;Point to PCI address register
587
;55 XX GPIO data register
588
mov eax, CX55x0_ID + 090h
590
;Point to PCI data register (CFCh)
608
;Point to PCI address register
610
;55 XX GPIO data register
611
mov eax, CX55x0_ID + 090h
613
;Point to PCI data register (CFCh)
626
Draco9210SetDataOut()
630
;Point to PCI address register
632
;55 XX GPIO data register
633
mov eax, CX55x0_ID + 090h
635
;Point to PCI data register (CFCh)
648
Draco9210ClearDataOut()
652
;Point to PCI address register
654
mov eax, CX55x0_ID + 090h;
655
;55 XX GPIO data register
657
;Point to PCI data register (CFCh)
662
and ah, NOT DATAOUT9210
670
Draco9210ReadDataIn()
672
unsigned char readdata;
676
;Point to PCI address register
678
;55 XX GPIO data register
679
mov eax, CX55x0_ID + 090h
681
;Point to PCI data register (CFCh)
685
;Preserve just Data IN bit
701
Draco9210ToggleClock()
705
;Point to PCI address register
707
;55 XX GPIO data register
708
mov eax, CX55x0_ID + 090h
709
;Point to PCI data register (CFCh)
718
out 0EDh, al /* IOPAUSE */
719
;Point to PCI address register
721
;55 XX GPIO data register
722
mov eax, CX55x0_ID + 090h
724
;Point to PCI data register (CFCh)
729
and ah, NOT CLOCK9210
736
#elif defined(linux) /* Linux */
751
Draco9210SetDataOut()
755
Draco9210ClearDataOut()
759
Draco9210ReadDataIn()
763
Draco9210ToggleClock()
770
Draco9210ReadReg(unsigned char index)
775
Draco9210ToggleClock();
776
Draco9210SetDataOut();
777
Draco9210ToggleClock();
778
Draco9210ClearDataOut();
779
Draco9210ToggleClock();
780
Draco9210ClearDataOut();
781
Draco9210ToggleClock();
782
Draco9210ClearDataOut();
783
Draco9210ToggleClock();
785
DracoWriteData(index);
786
DracoReadData(&data);
792
Draco9210WriteReg(unsigned char index, unsigned char data)
796
Draco9210ToggleClock();
798
Draco9210SetDataOut();
799
Draco9210ToggleClock();
801
Draco9210ClearDataOut();
802
Draco9210ToggleClock();
804
Draco9210ClearDataOut();
805
Draco9210ToggleClock();
807
Draco9210SetDataOut();
808
Draco9210ToggleClock();
810
DracoWriteData(index);
811
DracoWriteData(data);
813
Draco9210ClearDataOut();
814
Draco9210ToggleClock();
817
Draco9210ToggleClock();
818
Draco9210ToggleClock();