1/* $XFree86$ */
2/*
3 * $Workfile: dora9211.c $
4 * $Revision: 1.1.1.1 $
5 *
6 * File Contents: This file contains the panel functions to interface
7 *                the dorado platform.
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 "dora9211.h"
143
144void
145Dorado_Get_9211_Details(unsigned long flags, PPnl_PanelParams pParam)
146{
147   unsigned long DPanelType;
148   int i;
149
150   for (i = 0; i < 0x7fff; i++) {
151   }
152
153   Dorado9211GpioInit();
154
155   for (i = 0; i < 5; i++)
156      toggle_Centaurus_9211_clock();
157
158   if (flags & PNL_PANELCHIP) {
159      DPanelType = Dorado9211ReadReg(0x430);
160
161      if ((DPanelType & 0xFFFF0000) == 0x92110000) {	/* found 9211 */
162	 /* check the values for revision ID */
163	 if (DPanelType >= 0x92110301)
164	    pParam->PanelChip = PNL_9211_C;
165	 else if ((DPanelType >= 0x92110101) && (DPanelType < 0x92110301))
166	    pParam->PanelChip = PNL_9211_A;
167	 else
168	    pParam->PanelChip = PNL_UNKNOWN_CHIP;
169      } else {				/* no 9211 present */
170	 pParam->PanelChip = PNL_UNKNOWN_CHIP;
171      }
172   }
173
174   if ((pParam->PanelChip != PNL_UNKNOWN_CHIP) && (flags & PNL_PANELSTAT)) {
175      unsigned long PanelTypeOrg;
176      unsigned char Panel_2Byte;
177
178      DPanelType = Dorado9211ReadReg(0x438);
179      DPanelType &= 0x00e8e8e8;
180      DPanelType |= 0x00170000;
181      Dorado9211WriteReg(0x438, DPanelType);
182      DPanelType = 0;
183
184      DPanelType = Dorado9211ReadReg(0x434);
185      DPanelType = (DPanelType >> (DRD_LCDRESGPIO1 + 1));
186      PanelTypeOrg = DPanelType >> 8;
187      Panel_2Byte = (unsigned char)PanelTypeOrg;
188      Panel_2Byte = (Panel_2Byte >> (DRD_LCDRESGPIO2 - DRD_LCDRESGPIO1 - 1));
189      DPanelType = (DPanelType | ((unsigned int)Panel_2Byte << 8));
190      DPanelType = DPanelType >> 1;
191      PanelTypeOrg = DPanelType >> 8;
192      Panel_2Byte = (unsigned char)PanelTypeOrg;
193      Panel_2Byte = (Panel_2Byte >> (DRD_LCDRESGPIO3 - DRD_LCDRESGPIO2 - 1));
194      DPanelType = (DPanelType | ((unsigned int)Panel_2Byte << 8));
195      DPanelType = DPanelType >> 1;
196      PanelTypeOrg = DPanelType >> 8;
197      Panel_2Byte = (unsigned char)PanelTypeOrg;
198      Panel_2Byte = (Panel_2Byte >> (DRD_LCDRESGPIO4 - DRD_LCDRESGPIO3 - 1));
199      DPanelType = (DPanelType | ((unsigned int)Panel_2Byte << 8));
200      DPanelType = DPanelType >> 5;
201      DPanelType &= 0xf;
202
203      switch (DPanelType) {
204      case 8:
205	 pParam->PanelStat.XRes = 800;
206	 pParam->PanelStat.YRes = 600;
207	 pParam->PanelStat.Depth = 18;
208	 pParam->PanelStat.MonoColor = PNL_COLOR_PANEL;
209	 pParam->PanelStat.Type = PNL_TFT;
210	 break;
211
212      case 9:
213	 pParam->PanelStat.XRes = 640;
214	 pParam->PanelStat.YRes = 480;
215	 pParam->PanelStat.Depth = 8;
216	 pParam->PanelStat.MonoColor = PNL_COLOR_PANEL;
217	 pParam->PanelStat.Type = PNL_SSTN;
218	 break;
219
220      case 10:
221	 pParam->PanelStat.XRes = 1024;
222	 pParam->PanelStat.YRes = 768;
223	 pParam->PanelStat.Depth = 18;
224	 pParam->PanelStat.MonoColor = PNL_COLOR_PANEL;
225	 pParam->PanelStat.Type = PNL_TFT;
226	 break;
227      case 0:
228      case 1:
229      case 2:
230      case 3:
231      case 4:
232      case 5:
233      case 6:
234      case 7:
235      case 11:
236	 pParam->PanelStat.XRes = 640;
237	 pParam->PanelStat.YRes = 480;
238	 pParam->PanelStat.Depth = 16;
239	 pParam->PanelStat.MonoColor = PNL_COLOR_PANEL;
240	 pParam->PanelStat.Type = PNL_DSTN;
241	 break;
242      case 12:
243	 pParam->PanelStat.XRes = 640;
244	 pParam->PanelStat.YRes = 480;
245	 pParam->PanelStat.Depth = 18;
246	 pParam->PanelStat.MonoColor = PNL_COLOR_PANEL;
247	 pParam->PanelStat.Type = PNL_TFT;
248	 break;
249      case 13:
250	 pParam->PanelStat.XRes = 1024;
251	 pParam->PanelStat.YRes = 768;
252	 pParam->PanelStat.Depth = 24;
253	 pParam->PanelStat.MonoColor = PNL_COLOR_PANEL;
254	 pParam->PanelStat.Type = PNL_DSTN;
255	 break;
256      case 14:
257	 pParam->PanelStat.XRes = 640;
258	 pParam->PanelStat.YRes = 480;
259	 pParam->PanelStat.Depth = 8;
260	 pParam->PanelStat.MonoColor = PNL_MONO_PANEL;
261	 pParam->PanelStat.Type = PNL_DSTN;
262	 break;
263      case 15:
264	 pParam->PanelStat.XRes = 800;
265	 pParam->PanelStat.YRes = 600;
266	 pParam->PanelStat.Depth = 16;
267	 pParam->PanelStat.MonoColor = PNL_COLOR_PANEL;
268	 pParam->PanelStat.Type = PNL_DSTN;
269	 break;
270      default:
271	 break;
272      }
273   }
274   /* if block end */
275}
276
277void
278Dorado9211Init(Pnl_PanelStat * pstat)
279{
280   int mode;
281   unsigned long orig_value, pm_value;
282
283   gfx_delay_milliseconds(100);
284   Dorado9211GpioInit();
285
286   Dorado9211ToggleClock();
287   Dorado9211ToggleClock();
288   Dorado9211ToggleClock();
289   Dorado9211ToggleClock();
290   Dorado9211ToggleClock();
291
292   gfx_delay_milliseconds(100);
293
294   Dorado9211ToggleClock();
295   Dorado9211ToggleClock();
296   Dorado9211ToggleClock();
297   Dorado9211ToggleClock();
298   Dorado9211ToggleClock();
299
300   Dorado9211WriteReg(CS92xx_LCD_PWR_MAN, 0x0);
301
302   gfx_delay_milliseconds(100);
303   gfx_delay_milliseconds(100);
304
305   /* LOOP THROUGH THE AVAILABLE MODES TO FIND A MATCH */
306   for (mode = 0; mode < NUM_92XX_MODES; mode++) {
307      if ((FPModeParams[mode].xres == pstat->XRes) &&
308	  (FPModeParams[mode].yres == pstat->YRes) &&
309	  (FPModeParams[mode].bpp == pstat->Depth) &&
310	  (FPModeParams[mode].panel_type == pstat->Type) &&
311	  (FPModeParams[mode].color_type == pstat->MonoColor)) {
312
313	 /* SET THE 92xx FOR THE SELECTED MODE */
314	 CS92xx_MODE *pMode = &FPModeParams[mode];
315
316	 Dorado9211WriteReg(CS92xx_LCD_PAN_TIMING1, pMode->panel_timing1);
317	 Dorado9211WriteReg(CS92xx_LCD_PAN_TIMING2, pMode->panel_timing2);
318	 Dorado9211WriteReg(CS92xx_LCD_DITH_FR_CNTRL,
319			    pMode->rev_C_dither_frc);
320	 Dorado9211WriteReg(CS92xx_BLUE_LSFR_SEED, pMode->blue_lsfr_seed);
321	 Dorado9211WriteReg(CS92xx_RED_GREEN_LSFR_SEED,
322			    pMode->red_green_lsfr_seed);
323	 DoradoProgramFRMload();
324	 Dorado9211WriteReg(CS92xx_LCD_MEM_CNTRL, pMode->memory_control);
325	 Dorado9211WriteReg(CS92xx_LCD_PWR_MAN, pMode->power_management);
326	 gfx_delay_milliseconds(100);
327	 gfx_delay_milliseconds(100);
328	 Dorado9211ClearCS();
329
330	 /* This code is added to take care of Panel initialization.
331	  * Irrespective of Xpressrom is enabling the panel or not.
332	  */
333	 orig_value = READ_VID32(0X04);
334	 WRITE_VID32(0x04, 0x00200141);
335	 gfx_delay_milliseconds(21);
336	 pm_value = gfx_ind(0x9030);
337
338	 pm_value |= 0x400;
339	 gfx_outd(0x9030, pm_value);
340	 gfx_delay_milliseconds(4);
341	 orig_value &= 0xfff1ffff;
342	 WRITE_VID32(0X4, orig_value);
343	 return;
344      }					/*end if() */
345   }					/*end for() */
346
347}
348
349void
350Dorado9211SetCS(void)
351{
352   unsigned long value;
353
354   value = gfx_ind(DRD_CSP9211IN);
355   gfx_outd(DRD_CSP9211OUT, value | DRD_CS9211);
356}
357
358void
359Dorado9211ClearCS(void)
360{
361   unsigned long value;
362
363   value = gfx_ind(DRD_CSP9211IN);
364   gfx_outd(DRD_CSP9211OUT, value & (~DRD_CS9211));
365}
366
367void
368Dorado9211SetDataOut(void)
369{
370   unsigned long value;
371
372   value = gfx_ind(DRD_DATAOUTP9211IN);
373   gfx_outd(DRD_DATAOUTP9211OUT, value | DRD_DATAIN9211);
374}
375
376void
377Dorado9211ClearDataOut(void)
378{
379   unsigned long value;
380
381   value = gfx_ind(DRD_DATAOUTP9211IN);
382   gfx_outd(DRD_DATAOUTP9211OUT, value & (~DRD_DATAIN9211));
383}
384
385unsigned char
386Dorado9211ReadDataIn(void)
387{
388   unsigned char readdata = 0;
389   unsigned long value;
390
391   /* why to read 4 times ??? */
392   value = gfx_ind(DRD_DATAINP9211IN);
393   value = gfx_ind(DRD_DATAINP9211IN);
394   value = gfx_ind(DRD_DATAINP9211IN);
395   value = gfx_ind(DRD_DATAINP9211IN);
396   if (value & DRD_DATAOUT9211)
397      readdata = 1;
398   return (readdata);
399}
400
401void
402Dorado9211ToggleClock(void)
403{
404   Dorado9211SetClock();
405   Dorado9211ClearClock();
406}
407
408void
409Dorado9211SetClock(void)
410{
411   unsigned long value;
412
413   value = gfx_ind(DRD_CLOCKP9211IN);
414   gfx_outd(DRD_CLOCKP9211OUT, value | DRD_CLOCK9211);
415}
416
417void
418Dorado9211ClearClock(void)
419{
420   unsigned long value;
421
422   value = gfx_ind(DRD_CLOCKP9211IN);
423   gfx_outd(DRD_CLOCKP9211OUT, value & (~DRD_CLOCK9211));
424}
425
426void
427Dorado9211GpioInit(void)
428{
429   unsigned long value;
430
431   /* set output enable on gpio 7, 9, 11 */
432   gfx_outd((DRD_GEODE_GPIO_BASE + DRD_GEODE_GPPIN_SEL), DRD_CLOCK9211CFG);
433   gfx_outd((DRD_GEODE_GPIO_BASE + DRD_GEODE_GPPIN_CFG), 3);
434   /* set output enable on gpio 7, 9, 11 */
435   gfx_outd((DRD_GEODE_GPIO_BASE + DRD_GEODE_GPPIN_SEL), DRD_CS9211CFG);
436   gfx_outd((DRD_GEODE_GPIO_BASE + DRD_GEODE_GPPIN_CFG), 3);
437   /* set output enable on gpio 7, 9, 18 */
438   gfx_outd((DRD_GEODE_GPIO_BASE + DRD_GEODE_GPPIN_SEL), DRD_DATAIN9211CFG);
439   gfx_outd((DRD_GEODE_GPIO_BASE + DRD_GEODE_GPPIN_CFG), 3);
440   /* disable on gpio 11 - This is the output from the 9211 */
441   gfx_outd((DRD_GEODE_GPIO_BASE + DRD_GEODE_GPPIN_SEL), DRD_DATAOUT9211CFG);
442   gfx_outd((DRD_GEODE_GPIO_BASE + DRD_GEODE_GPPIN_CFG), 0);
443   /* Set all PINS low */
444   value = gfx_ind(DRD_GEODE_GPIO_BASE + DRD_GEODE_GPDI0);
445   value &= ~(DRD_CS9211 | DRD_CLOCK9211 | DRD_DATAIN9211);
446   gfx_outd((DRD_GEODE_GPIO_BASE + DRD_GEODE_GPDO0), value);
447}
448
449unsigned long
450Dorado9211ReadReg(unsigned short index)
451{
452
453   unsigned char i, readbit;
454   unsigned long data;
455
456   Dorado9211ClearDataOut();
457
458   Dorado9211SetCS();
459   Dorado9211ToggleClock();
460
461   Dorado9211SetDataOut();
462   Dorado9211ToggleClock();
463
464   for (i = 0; i < 12; i++) {
465      if (index & 0x1) {
466	 Dorado9211SetDataOut();
467      } else {
468	 Dorado9211ClearDataOut();
469      }
470      Dorado9211ToggleClock();
471      index >>= 1;
472   }
473
474   Dorado9211ClearDataOut();
475   Dorado9211ToggleClock();
476
477   /* Idle clock, 7 clocks, no data set */
478
479   Dorado9211ToggleClock();
480   Dorado9211ToggleClock();
481   Dorado9211ToggleClock();
482   Dorado9211ToggleClock();
483   Dorado9211ToggleClock();
484   Dorado9211ToggleClock();
485   Dorado9211ToggleClock();
486
487   data = 0;
488   for (i = 0; i < 32; i++) {
489      Dorado9211ToggleClock();
490      readbit = Dorado9211ReadDataIn();
491      data |= (((unsigned long)readbit) << i);
492   }
493
494   Dorado9211ClearCS();
495   Dorado9211ToggleClock();
496   return (data);
497
498}
499
500void
501Dorado9211WriteReg(unsigned short index, unsigned long data)
502{
503
504   unsigned char i;
505
506   Dorado9211ClearDataOut();
507   Dorado9211SetDataOut();
508   Dorado9211SetCS();
509   Dorado9211ToggleClock();
510   Dorado9211SetDataOut();
511   Dorado9211ToggleClock();
512
513   for (i = 0; i < 12; i++) {
514      if (index & 0x1) {
515	 Dorado9211SetDataOut();
516      } else {
517	 Dorado9211ClearDataOut();
518      }
519      Dorado9211ToggleClock();
520      index >>= 1;
521   }
522
523   Dorado9211SetDataOut();
524   Dorado9211ToggleClock();
525
526   for (i = 0; i < 32; i++) {
527      if (data & 0x1) {
528	 Dorado9211SetDataOut();
529      } else {
530	 Dorado9211ClearDataOut();
531      }
532      Dorado9211ToggleClock();
533      data >>= 1;
534   }
535
536   Dorado9211ClearCS();
537
538   Dorado9211ToggleClock();
539   Dorado9211ToggleClock();
540   Dorado9211ToggleClock();
541   Dorado9211ToggleClock();
542}
543
544void
545DoradoProgramFRMload(void)
546{
547   unsigned long DoradoFRMtable[] = {
548
549      0x00000000,
550      0x00000000,
551      0x01000100,
552      0x01000100,
553      0x01010101,
554      0x01010101,
555      0x02081041,
556      0x02081041,
557      0x10111111,
558      0x11111101,
559      0x49249241,
560      0x12412492,
561      0x92244891,
562      0x92244891,
563      0x22252525,
564      0x22252525,
565      0x528294a5,
566      0x2528494a,
567      0x294a5295,
568      0x294a5295,
569      0x54a54a95,
570      0x2952a52a,
571      0x2a552a55,
572      0x2a552a55,
573      0x554aa955,
574      0x2a9552aa,
575      0x2aaa5555,
576      0x2aaa5555,
577      0x55555555,
578      0x2aaaaaaa,
579      0x55555555,
580      0x55555555,
581      0xaaaaaaab,
582      0x55555555,
583      0x5555aaab,
584      0x5555aaab,
585      0xaab556ab,
586      0x556aad55,
587      0x55ab55ab,
588      0x55ab55ab,
589      0xab5ab56b,
590      0x56ad5ad5,
591      0x56b5ad6b,
592      0x56b5ad6b,
593      0xad6d6b5b,
594      0x5ad6b6b6,
595      0x5b5b5b5b,
596      0x5b5b5b5b,
597      0x5F6db6db,
598      0x5F6db6db,
599      0xF776F776,
600      0xF776F776,
601      0xFBDEFBDE,
602      0xFBDEFBDE,
603      0x7eFFBFF7,
604      0x7eFFBFF7,
605      0xFF7FF7F7,
606      0xFF7FF7F7,
607      0xFF7FFF7F,
608      0xFF7FFF7F,
609      0xFFF7FFFF,
610      0xFFF7FFFF,
611      0xFFFFFFFF,
612      0xFFFFFFFF,
613   };
614
615   unsigned char i;
616   unsigned short index;
617   unsigned long data;
618
619   Dorado9211WriteReg(CS92xx_FRM_MEMORY_INDEX, 0);
620   index = CS92xx_FRM_MEMORY_DATA;
621   for (i = 0; i < 64; i += 2) {
622      data = DoradoFRMtable[i];
623      Dorado9211WriteReg(index, data);
624      data = DoradoFRMtable[i + 1];
625      Dorado9211WriteReg(index, data);
626   }
627
628/*
629 * The first FRM location (64 bits) does not program correctly.
630 * This location always reads back with the last value programmed.
631 * ie. If 32 64-bit values are programmed, location 0 reads back as the 32nd
632 * If 30 locations are programmed, location 0 reads back as the 30th, etc.
633 * Fix this by re-writing location 0 after programming all 64 in the writeFRM
634 * loop in RevCFrmload() in CS9211.
635 */
636
637   Dorado9211WriteReg(CS92xx_FRM_MEMORY_INDEX, 0);
638   Dorado9211WriteReg(CS92xx_FRM_MEMORY_DATA, 0);
639   Dorado9211WriteReg(CS92xx_FRM_MEMORY_DATA, 0);
640
641}
642
643/******************************************************************************
644 * void Dorado_Enable_Power((void);
645 * Enables the power of the CX9211 on Dorado board.
646 ******************************************************************************
647 */
648
649void
650Dorado_Power_Up(void)
651{
652   Dorado9211WriteReg(CS92xx_LCD_PWR_MAN, 0x01000000);
653   return;
654
655}					/* disable_Centaurus_Power */
656
657/******************************************************************************
658 * void Dorado_Disable_Power((void);
659 * Disables the power of the CX9211 on Dorado board.
660 *****************************************************************************
661 */
662
663void
664Dorado_Power_Down(void)
665{
666   Dorado9211WriteReg(CS92xx_LCD_PWR_MAN, 0x0);
667   return;
668
669}					/* disable_Centaurus_Power */
670
671void
672Dorado_Save_Panel_State(void)
673{
674
675   /* set 9211 registers using the desired panel settings     */
676   cs9211_regs.panel_timing1 = Dorado9211ReadReg(CS92xx_LCD_PAN_TIMING1);
677   cs9211_regs.panel_timing2 = Dorado9211ReadReg(CS92xx_LCD_PAN_TIMING2);
678
679   cs9211_regs.dither_frc_ctrl = Dorado9211ReadReg(CS92xx_LCD_DITH_FR_CNTRL);
680   cs9211_regs.blue_lsfr_seed = Dorado9211ReadReg(CS92xx_BLUE_LSFR_SEED);
681   cs9211_regs.red_green_lsfr_seed =
682	 Dorado9211ReadReg(CS92xx_RED_GREEN_LSFR_SEED);
683
684   /* CentaurusProgramFRMload(); */
685   cs9211_regs.memory_control = Dorado9211ReadReg(CS92xx_LCD_MEM_CNTRL);
686
687   /* Set the power register last. This will turn the panel on at the 9211. */
688   cs9211_regs.power_management = Dorado9211ReadReg(CS92xx_LCD_PWR_MAN);
689   cs9211_regs.panel_state = cs9211_regs.power_management;
690}
691
692void
693Dorado_Restore_Panel_State(void)
694{
695   unsigned long off_data = 0;
696
697   /* Before restoring the 9211 registers, power off the 9211. */
698
699   Dorado9211WriteReg(CS92xx_LCD_PWR_MAN, off_data);
700
701   /* set 9211 registers using the desired panel settings    */
702   Dorado9211WriteReg(CS92xx_LCD_PAN_TIMING1, cs9211_regs.panel_timing1);
703   Dorado9211WriteReg(CS92xx_LCD_PAN_TIMING2, cs9211_regs.panel_timing2);
704   /* load the LSFR seeds */
705   Dorado9211WriteReg(CS92xx_LCD_DITH_FR_CNTRL, cs9211_regs.dither_frc_ctrl);
706   Dorado9211WriteReg(CS92xx_BLUE_LSFR_SEED, cs9211_regs.blue_lsfr_seed);
707   Dorado9211WriteReg(CS92xx_RED_GREEN_LSFR_SEED,
708		      cs9211_regs.red_green_lsfr_seed);
709
710   Dorado9211WriteReg(CS92xx_LCD_MEM_CNTRL, cs9211_regs.memory_control);
711   /* Set the power register last. This will turn the panel on at the 9211. */
712   Dorado9211WriteReg(CS92xx_LCD_PWR_MAN, cs9211_regs.power_management);
713}
714