1/* Copyright (c) 2005 Advanced Micro Devices, Inc.
2 *
3 * Permission is hereby granted, free of charge, to any person obtaining a copy
4 * of this software and associated documentation files (the "Software"), to
5 * deal in the Software without restriction, including without limitation the
6 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7 * sell copies of the Software, and to permit persons to whom the Software is
8 * furnished to do so, subject to the following conditions:
9 *
10 * The above copyright notice and this permission notice shall be included in
11 * all copies or substantial portions of the Software.
12 *
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19 * IN THE SOFTWARE.
20 *
21 * Neither the name of the Advanced Micro Devices, Inc. nor the names of its
22 * contributors may be used to endorse or promote products derived from this
23 * software without specific prior written permission.
24 * */
25
26/*
27 * File Contents:   This file contains panel functions to interface with
28 *                  the centaraus platform.
29 *
30 * SubModule:       Geode FlatPanel library
31 * */
32
33#include "cen9211.h"
34
35static unsigned char sioc2_orig_val;
36static unsigned char must_restore_97317 = FALSE;
37
38/********************************************************************
39 *
40 * PASS_FAIL init_GPIO(void);
41 * Initializes the GPIO pins in the Cx5530 or the National PC97317
42 * for use with a 9211 on a Marmot or Centaurus board. Uses
43 * the global variables RdPCIVal and sioc2_orig_val.
44 *
45 *********************************************************************/
46
47unsigned char
48init_Centaurus_GPIO(void)
49{
50    unsigned char reg_val;
51    static unsigned char first_time = TRUE;
52
53    /* The Centaurus board uses ports 1 and 2 of the 97317 for GPIO.
54     * These ports require bank 0 to be active. The first thing we will
55     * do is verify that bank 0 is active and set it if it is not.
56     */
57
58    /* set the index for access to the configuration register */
59    gfx_outb(CENT_CONFIG_INDEX, CENT_SIOC2);
60    reg_val = gfx_inb(CENT_CONFIG_DATA);
61
62    /* set to bank 0 */
63    if (reg_val & CENT_GPIO_BANK_SELECT) {
64        gfx_outb(CENT_CONFIG_DATA,
65                 (unsigned char) (reg_val & ~CENT_GPIO_BANK_SELECT));
66    }
67
68    /* If this is the first time we have modified sioc2, we must
69     * save the current value (set by the BIOS) for restoration by
70     * the calling program, set the global flag must_restore_97317, and set
71     * first_time to FALSE.
72     */
73
74    if (first_time == TRUE) {
75        sioc2_orig_val = reg_val;
76        must_restore_97317 = TRUE;
77        first_time = FALSE;
78    }
79
80    /* set port 1 direction */
81    reg_val = gfx_inb(CENT_PORT1_DIRECTION);
82
83    /* make GPIO 14 and 17 outputs  */
84    reg_val |= CENT_97317_CLOCK_MASK | CENT_97317_DATA_OUT_MASK;
85    gfx_outb(CENT_PORT1_DIRECTION, reg_val);
86
87    /* set port 2 direction */
88    reg_val = gfx_inb(CENT_PORT2_DIRECTION);
89
90    /* make GPIO 20 an output */
91
92    reg_val |= CENT_97317_CHIP_SEL_MASK;
93
94    /* make GPIO 21 an input */
95
96    reg_val &= ~CENT_97317_DATA_IN_MASK;
97    gfx_outb(CENT_PORT2_DIRECTION, reg_val);
98
99    /* make GPIO 14 and 17 push-pull */
100
101    reg_val = gfx_inb(CENT_PORT1_OUTPUT_TYPE);
102    reg_val |= CENT_97317_CLOCK_MASK | CENT_97317_DATA_OUT_MASK;
103    gfx_outb(CENT_PORT1_OUTPUT_TYPE, reg_val);
104
105    /* make GPIO 20 and 21 push-pull */
106    reg_val = gfx_inb(CENT_PORT2_OUTPUT_TYPE);
107    reg_val |= CENT_97317_CHIP_SEL_MASK | CENT_97317_DATA_IN_MASK;
108    gfx_outb(CENT_PORT2_OUTPUT_TYPE, reg_val);
109    return CENT_PASS;
110
111}                               /* end init_GPIO() */
112
113/*********************************************************************
114 *
115 * PASS_FAIL init_9211(void);
116 * Initializes (sets to 0) the clock, chip select, and data pins
117 * of the Cx9211 on a Marmot or Centaurus board.
118 *
119 **********************************************************************/
120
121unsigned char
122init_Centaurus_9211(void)
123{
124    unsigned char ReadData;
125
126    /* Uses the 97317 for GPIO.
127     * we will use the clock port define for port 1
128     */
129    ReadData = gfx_inb(CENT_97317_CLOCK_PORT);
130    ReadData &= ~CENT_97317_CLOCK_MASK & ~CENT_97317_DATA_OUT_MASK;
131    gfx_outb(CENT_97317_CLOCK_PORT, ReadData);
132    /* we will use the chip select port define for port 2 */
133    ReadData = gfx_inb(CENT_97317_CHIP_SELECT);
134    ReadData &= ~CENT_97317_CHIP_SEL_MASK & ~CENT_97317_DATA_IN_MASK;
135    gfx_outb(CENT_97317_CHIP_SELECT, ReadData);
136    return (CENT_PASS);
137
138}                               /*end init_9211() */
139
140/******************************************************************
141 *
142 * PASS_FAIL restore_97317_SIOC2(void);
143 * Restores the original value to the 97317 SIOC2 register using
144 * the global variable sioc2_orig_val. Returns PASS if the value
145 * was written, FAIL if not.
146 *
147 *******************************************************************/
148
149unsigned char
150restore_Centaurus_97317_SIOC2(void)
151{
152    /* set the global flag */
153    if (must_restore_97317 == TRUE) {
154        unsigned char cfg;
155
156        /* set the index for access to the configuration register */
157        gfx_outb(CENT_CONFIG_INDEX, CENT_SIOC2);
158
159        /* restore the value */
160        gfx_outb(CENT_CONFIG_DATA, sioc2_orig_val);
161
162        /* now read and verify */
163        cfg = gfx_inb(CENT_CONFIG_DATA);
164        if (cfg == sioc2_orig_val)
165            return (CENT_PASS);
166        else
167            return (CENT_FAIL);
168
169    }                           /* end if() */
170    return (CENT_FAIL);
171
172}                               /* end restore_97317_SIOC2bank() */
173
174/* -----------------------------------------------------------------------
175 *
176 * SET_FLAT_PANEL_MODE
177 *
178 * This routine sets the specified flat panel moden parameters in
179 * the 9211.
180 * Returns PASS if successful, FAIL if the mode parameters could
181 * not be set.
182 *
183 *------------------------------------------------------------------------*/
184
185unsigned char
186set_Centaurus_92xx_mode(Pnl_PanelStat * pstat)
187{
188    int mode;
189
190    /* LOOP THROUGH THE AVAILABLE MODES TO FIND A MATCH */
191
192    for (mode = 0; mode < NUM_92XX_MODES; mode++) {
193        if ((FPModeParams[mode].xres == pstat->XRes) &&
194            (FPModeParams[mode].yres == pstat->YRes) &&
195            (FPModeParams[mode].bpp == pstat->Depth) &&
196            (FPModeParams[mode].panel_type == pstat->Type) &&
197            (FPModeParams[mode].color_type == pstat->MonoColor)) {
198
199            /* SET THE 92xx FOR THE SELECTED MODE */
200            set_Centaurus_92xx_mode_params(mode);
201            return (CENT_PASS);
202        }                       /* end if() */
203    }                           /* end for() */
204    return (CENT_FAIL);
205
206}                               /* end set_Centaurus_92xx_mode() */
207
208/*-------------------------------------------------------------------
209 *
210 * SET_92XX_MODE_PARAMS
211 * This routine sets the 9211 mode parameters.
212 *
213 *-------------------------------------------------------------------*/
214
215void
216set_Centaurus_92xx_mode_params(int mode)
217{
218    CS92xx_MODE *pMode = &FPModeParams[mode];
219    unsigned long off_data = 0;
220
221    /* Turn the 92xx power off before setting any new parameters.
222     * Since we are going to reset all the power bit positions, we will
223     * force the power register to 0.
224     */
225
226    Centaurus_write_gpio(FOUR_BYTES, CS92xx_LCD_PWR_MAN, off_data);
227
228    /* set 9211 registers using the desired panel settings */
229
230    Centaurus_write_gpio(FOUR_BYTES,
231                         CS92xx_LCD_PAN_TIMING1, pMode->panel_timing1);
232
233    Centaurus_write_gpio(FOUR_BYTES,
234                         CS92xx_LCD_PAN_TIMING2, pMode->panel_timing2);
235
236    if (Pnl_Rev_ID == PNL_9211_C) {
237
238        /* load the LSFR seeds */
239        Centaurus_write_gpio(FOUR_BYTES,
240                             CS92xx_LCD_DITH_FR_CNTRL, pMode->rev_C_dither_frc);
241
242        Centaurus_write_gpio(FOUR_BYTES,
243                             CS92xx_BLUE_LSFR_SEED, pMode->blue_lsfr_seed);
244
245        Centaurus_write_gpio(FOUR_BYTES,
246                             CS92xx_RED_GREEN_LSFR_SEED,
247                             pMode->red_green_lsfr_seed);
248    }
249    else {
250
251        Centaurus_write_gpio(FOUR_BYTES,
252                             CS92xx_LCD_DITH_FR_CNTRL, pMode->pre_C_dither_frc);
253
254        Centaurus_write_gpio(FOUR_BYTES,
255                             CS92xx_LCD_BLOCK_SEL1, pMode->block_select1);
256
257        Centaurus_write_gpio(FOUR_BYTES,
258                             CS92xx_LCD_BLOCK_SEL2, pMode->block_select2);
259
260        Centaurus_write_gpio(FOUR_BYTES,
261                             CS92xx_LCD_DISPER1, pMode->dispersion1);
262
263        Centaurus_write_gpio(FOUR_BYTES,
264                             CS92xx_LCD_DISPER2, pMode->dispersion2);
265
266        CentaurusProgramFRMload();
267    }
268
269    Centaurus_write_gpio(FOUR_BYTES, CS92xx_LCD_MEM_CNTRL,
270                         pMode->memory_control);
271
272    /* Set the power register last. This will turn the panel on at the 9211. */
273
274    Centaurus_write_gpio(FOUR_BYTES,
275                         CS92xx_LCD_PWR_MAN, pMode->power_management);
276
277}                               /* end set_Centaurus_92xx_mode_params() */
278
279void
280Centaurus_write_gpio(int width, ULONG address, unsigned long data)
281{
282    int num_clock_toggles;
283    int count;
284    unsigned long Addr = address;
285
286    enable_Centaurus_9211_chip_select();
287
288    /* Write 1 Clock period of no valid transfer */
289    write_Centaurus_CX9211_GPIO(CENT_NO_DATA);
290
291    /* Write 1 control bit (the data book calls this the control bar write) */
292    write_Centaurus_CX9211_GPIO(0x1);
293
294    /* Write the 12-bit address */
295    for (count = 0; count < 12; count++) {
296        write_Centaurus_CX9211_GPIO((unsigned char) (Addr & 0x01));
297        /*the 9211 expects data LSB->MSB */
298        Addr = Addr >> 1;
299    }
300
301    /* write */
302    write_Centaurus_CX9211_DWdata(data);
303
304    /* a write will require four toggles after disabling CS */
305    num_clock_toggles = CENT_NUM_WRITE_CLOCK_TOGGLES;
306    disable_Centaurus_9211_chip_select();
307
308    /* now toggle the clock */
309    for (count = 0; count < num_clock_toggles; count++) {
310        toggle_Centaurus_9211_clock();
311    }
312    return;
313
314}                               /* end Centaurus_write_gpio() */
315
316unsigned long
317Centaurus_read_gpio(int width, unsigned long address)
318{
319    int num_clock_toggles;
320    int count;
321    unsigned long Addr = address;
322    unsigned long data;
323
324    enable_Centaurus_9211_chip_select();
325
326    /* Write 1 Clock period of no valid transfer */
327    write_Centaurus_CX9211_GPIO(CENT_NO_DATA);
328
329    /* Write 1 control bit (the data book calls this the control bar write) */
330    write_Centaurus_CX9211_GPIO(0x1);
331
332    /* Write the 12-bit address */
333    for (count = 0; count < 12; count++) {
334        write_Centaurus_CX9211_GPIO((unsigned char) (Addr & 0x01));
335
336        /*the 9211 expects data LSB->MSB */
337        Addr = Addr >> 1;
338    }
339
340    data = read_Centaurus_CX9211_DWdata();
341
342    /* a read will require one toggle after disabling CS */
343    num_clock_toggles = CENT_NUM_READ_CLOCK_TOGGLES;
344    disable_Centaurus_9211_chip_select();
345
346    /* now toggle the clock */
347    for (count = 0; count < num_clock_toggles; count++) {
348        toggle_Centaurus_9211_clock();
349    }
350    return data;
351
352}                               /* end Centaurus_read_gpio() */
353
354/*******************************************************************
355 *
356 * void enable_Centaurus_9211_chip_select(void);
357 * Enables the chip select of the CX9211 using the National 97317
358 * on a Centaurus board.
359 *
360 *******************************************************************/
361
362void
363enable_Centaurus_9211_chip_select(void)
364{
365    unsigned char cs_port_val;
366
367    /* Set the chip select (GPIO20) high */
368    cs_port_val = gfx_inb(CENT_97317_CHIP_SELECT);
369    gfx_outb(CENT_97317_CHIP_SELECT,
370             (unsigned char) (cs_port_val | CENT_97317_CHIP_SEL_MASK));
371    return;
372}                               /* end enable_Centaurus_9211_chip_select() */
373
374/********************************************************************
375 *
376 * void disable_Centaurus_9211_chip_select(void);
377 * Disables the chip select of the CX9211 using the National 97317
378 * on a Centaurus board.
379 *
380 *******************************************************************/
381
382void
383disable_Centaurus_9211_chip_select(void)
384{
385    unsigned char cs_port_val;
386
387    /* Set the chip select (GPIO20) low */
388    cs_port_val = gfx_inb(CENT_97317_CHIP_SELECT);
389    gfx_outb(CENT_97317_CHIP_SELECT,
390             (unsigned char) (cs_port_val & ~CENT_97317_CHIP_SEL_MASK));
391    return;
392
393}                               /* end disable_Centaurus_9211_chip_select() */
394
395/**********************************************************************
396 *
397 * void toggle_Centaurus_9211_clock(void);
398 * Toggles the clock bit of the CX9211 using the National 97317 on a
399 * Centaurus board. Assumes the 9211 clock bit has previously been
400 * initialized to 0 (this way we do not have to waste GPIO cycles
401 * windowing the clock pulse).
402 *
403 **********************************************************************/
404
405void
406toggle_Centaurus_9211_clock(void)
407{
408    unsigned char port_val;
409
410    /* get the 97317 GPIO port contents for the 9211 clock */
411
412    port_val = gfx_inb(CENT_97317_CLOCK_PORT);
413    /* set the clock bit high */
414    gfx_outb(CENT_97317_CLOCK_PORT,
415             (unsigned char) (port_val | CENT_97317_CLOCK_MASK));
416
417    /* set the clock bit low */
418    gfx_outb(CENT_97317_CLOCK_PORT,
419             (unsigned char) (port_val & ~CENT_97317_CLOCK_MASK));
420
421}                               /* end toggle_Centaurus_9211_clock() */
422
423/********************************************************************
424 *
425 * void write_Centaurus_CX9211_GPIO(unsigned char databit);
426 * Writes the value in bit 0 of the value passed in databit to
427 * the 9211 through the GPIO interface of the National 97317 on a
428 * Centaurus board.
429 * NOTE: This function does not set or reset the chip select line!
430 *
431 *******************************************************************/
432
433void
434write_Centaurus_CX9211_GPIO(unsigned char databit)
435{
436    unsigned char data_port_val;
437
438    /* Set the data bit for (GPIO17) */
439    databit <<= 7;
440
441    /* read the value of the other bits in the 97317 data port */
442    data_port_val = gfx_inb(CENT_97317_DATA_OUTPORT);
443
444    /* set the bit accordingly */
445    data_port_val &= ~CENT_97317_DATA_OUT_MASK;
446    data_port_val |= databit;
447    gfx_outb(CENT_97317_DATA_OUTPORT, data_port_val);
448
449    /* clock the data */
450    toggle_Centaurus_9211_clock();
451    return;
452
453}                               /* end write_Centaurus_CX9211_GPIO() */
454
455/*****************************************************************
456 *
457 * void write_Centaurus_CX9211_DWdata(unsigned long data);
458 * Writes the doubleword value passed in data to the CX9211
459 * using GPIO Pins of the National 97317 on a Centaurus board.
460 * This function assumes the Direction register of the 97317
461 * and the address register of the CX9211 have been previously set.
462 * Uses the global variable count.
463 * NOTE: This function does not set or reset the chip select line!
464 *
465 ******************************************************************/
466
467void
468write_Centaurus_CX9211_DWdata(unsigned long data)
469{
470    int count;
471
472    /* Send the read/write command to the 9211 first. */
473
474    write_Centaurus_CX9211_GPIO(CENT_WRITE);
475
476    /* Now write the 32-bit Data */
477    for (count = 0; count < 32; count++) {
478        write_Centaurus_CX9211_GPIO((unsigned char) (data & 0x01));
479
480        /* the 9211 expects the data LSB->MSB */
481        data >>= 1;
482    }
483    return;
484
485}                               /* end write_Centaurus_CX9211_DWdata() */
486
487/*********************************************************************
488 *
489 * unsigned char read_Centaurus_CX9211_GPIO(void);
490 * Returns the current value of the databit of the 9211 in bit 0
491 * using the GPIO interface of the National 97317 on a Centaurus board.
492 * NOTE: This function does not set or reset the chip select line!
493 *
494 *********************************************************************/
495
496unsigned char
497read_Centaurus_CX9211_GPIO(void)
498{
499    unsigned char data_port_val;
500
501    toggle_Centaurus_9211_clock();
502
503    /* read the data */
504    data_port_val = gfx_inb(CENT_97317_DATA_INPORT);
505
506    /* Save the data from (GPIO21) as bit 0 */
507    data_port_val >>= 1;
508    return (data_port_val & 0x1);
509
510}                               /* end read_Centaurus_CX9211_GPIO() */
511
512/**********************************************************************
513 *
514 * void read_Centaurus_CX9211_DWdata(unsigned long *data);
515 * Reads a doubleword value from the CX9211 using GPIO Pins of
516 * the National 97317 on a Centaurus board.
517 * This function assumes the Direction register of the 97317 and
518 * the address register of the CX9211 have been previously set.
519 * NOTE: This function does not set or reset the chip select line!
520 *
521 ***********************************************************************/
522
523unsigned long
524read_Centaurus_CX9211_DWdata(void)
525{
526    unsigned char ReadData;
527    int count;
528    unsigned long Data;
529
530    /* Send read/write command word to the 9211 first. */
531    write_Centaurus_CX9211_GPIO(CENT_READ);
532
533    /* The data book (revision 0.1) states 8 clock periods of no valid data.
534     * However, the data becomes valid on the eighth clock, making the eighth
535     * clock valid. Since read_Centaurus_GPIO() toggles the clock before
536     * reading, we will only toggle the clock 7 times here.
537     */
538    for (count = 0; count < 7; count++) /* works */
539        toggle_Centaurus_9211_clock();
540
541    /* Now read the 32-bit Data, bit by bit in a single loop. */
542    Data = 0;
543    for (count = 0; count < 32; count++) {
544        ReadData = read_Centaurus_CX9211_GPIO();
545        /* 9211 sends data  LSB->MSB */
546        Data = Data | (((unsigned long) ReadData) << count);
547    }                           /* end for() */
548
549    return Data;
550
551}                               /* end read_Centaurus_CX9211_DWdata() */
552
553void
554Centaurus_Get_9211_Details(unsigned long flags, Pnl_PanelParams * pParam)
555{
556    unsigned long PanelType;
557    int i;
558
559    for (i = 0; i < 0x7fff; i++) {
560    }
561
562    init_Centaurus_GPIO();
563
564    for (i = 0; i < 5; i++)
565        toggle_Centaurus_9211_clock();
566
567    if (flags & PNL_PANELCHIP) {
568
569        PanelType = Centaurus_read_gpio(FOUR_BYTES, 0x430);
570        PanelType = Centaurus_read_gpio(FOUR_BYTES, 0x430);
571        if ((PanelType & 0xFFFF0000) == 0x92110000) {
572
573            /* found 9211 */
574            /* check the values for revision ID */
575            if (PanelType >= 0x92110301)
576                pParam->PanelChip = PNL_9211_C;
577            else if ((PanelType >= 0x92110101) && (PanelType < 0x92110301))
578                pParam->PanelChip = PNL_9211_A;
579            else
580                pParam->PanelChip = PNL_UNKNOWN_CHIP;
581        }
582        else {                  /* no 9211 present */
583            pParam->PanelChip = PNL_UNKNOWN_CHIP;
584        }
585        Pnl_Rev_ID = pParam->PanelChip;
586    }
587    /* if end */
588    if ((pParam->PanelChip != PNL_UNKNOWN_CHIP) && (flags & PNL_PANELSTAT)) {
589        PanelType = Centaurus_read_gpio(FOUR_BYTES, 0x438);
590        PanelType &= 0x00f8f8f8;
591        PanelType |= 0x00070000;
592        Centaurus_write_gpio(FOUR_BYTES, 0x438, PanelType);
593        PanelType = 0;
594        PanelType = Centaurus_read_gpio(FOUR_BYTES, 0x434);
595        PanelType = (PanelType >> 8);
596        PanelType &= 0x7;
597
598        switch (PanelType) {
599        case 0:
600            pParam->PanelStat.XRes = 800;
601            pParam->PanelStat.YRes = 600;
602            pParam->PanelStat.Depth = 18;
603            pParam->PanelStat.MonoColor = PNL_COLOR_PANEL;
604            pParam->PanelStat.Type = PNL_TFT;
605            break;
606        case 1:
607            pParam->PanelStat.XRes = 640;
608            pParam->PanelStat.YRes = 480;
609            pParam->PanelStat.Depth = 8;
610            pParam->PanelStat.MonoColor = PNL_COLOR_PANEL;
611            pParam->PanelStat.Type = PNL_SSTN;
612            break;
613        case 2:
614            pParam->PanelStat.XRes = 1024;
615            pParam->PanelStat.YRes = 768;
616            pParam->PanelStat.Depth = 18;
617            pParam->PanelStat.MonoColor = PNL_COLOR_PANEL;
618            pParam->PanelStat.Type = PNL_TFT;
619            break;
620        case 3:
621            pParam->PanelStat.XRes = 640;
622            pParam->PanelStat.YRes = 480;
623            pParam->PanelStat.Depth = 16;
624            pParam->PanelStat.MonoColor = PNL_COLOR_PANEL;
625            pParam->PanelStat.Type = PNL_DSTN;
626            break;
627        case 4:
628            pParam->PanelStat.XRes = 640;
629            pParam->PanelStat.YRes = 480;
630            pParam->PanelStat.Depth = 18;
631            pParam->PanelStat.MonoColor = PNL_COLOR_PANEL;
632            pParam->PanelStat.Type = PNL_TFT;
633            break;
634        case 5:
635            pParam->PanelStat.XRes = 1024;
636            pParam->PanelStat.YRes = 768;
637            pParam->PanelStat.Depth = 24;
638            pParam->PanelStat.MonoColor = PNL_COLOR_PANEL;
639            pParam->PanelStat.Type = PNL_DSTN;
640            break;
641        case 6:
642            pParam->PanelStat.XRes = 640;
643            pParam->PanelStat.YRes = 480;
644            pParam->PanelStat.Depth = 8;
645            pParam->PanelStat.MonoColor = PNL_MONO_PANEL;
646            pParam->PanelStat.Type = PNL_DSTN;
647            break;
648        case 7:
649            pParam->PanelStat.XRes = 800;
650            pParam->PanelStat.YRes = 600;
651            pParam->PanelStat.Depth = 16;
652            pParam->PanelStat.MonoColor = PNL_COLOR_PANEL;
653            pParam->PanelStat.Type = PNL_DSTN;
654            break;
655        default:
656            break;
657        }
658    }
659
660}
661
662void
663CentaurusProgramFRMload(void)
664{
665    unsigned long CentaurusFRMtable[] = {
666        0x00000000,
667        0x00000000,
668        0x01000100,
669        0x01000100,
670        0x01010101,
671        0x01010101,
672        0x02081041,
673        0x02081041,
674        0x10111111,
675        0x11111101,
676        0x49249241,
677        0x12412492,
678        0x92244891,
679        0x92244891,
680        0x22252525,
681        0x22252525,
682        0x528294a5,
683        0x2528494a,
684        0x294a5295,
685        0x294a5295,
686        0x54a54a95,
687        0x2952a52a,
688        0x2a552a55,
689        0x2a552a55,
690        0x554aa955,
691        0x2a9552aa,
692        0x2aaa5555,
693        0x2aaa5555,
694        0x55555555,
695        0x2aaaaaaa,
696        0x55555555,
697        0x55555555,
698        0xaaaaaaab,
699        0x55555555,
700        0x5555aaab,
701        0x5555aaab,
702        0xaab556ab,
703        0x556aad55,
704        0x55ab55ab,
705        0x55ab55ab,
706        0xab5ab56b,
707        0x56ad5ad5,
708        0x56b5ad6b,
709        0x56b5ad6b,
710        0xad6d6b5b,
711        0x5ad6b6b6,
712        0x5b5b5b5b,
713        0x5b5b5b5b,
714        0x5F6db6db,
715        0x5F6db6db,
716        0xF776F776,
717        0xF776F776,
718        0xFBDEFBDE,
719        0xFBDEFBDE,
720        0x7eFFBFF7,
721        0x7eFFBFF7,
722        0xFF7FF7F7,
723        0xFF7FF7F7,
724        0xFF7FFF7F,
725        0xFF7FFF7F,
726        0xFFF7FFFF,
727        0xFFF7FFFF,
728        0xFFFFFFFF,
729        0xFFFFFFFF,
730    };
731
732    unsigned char i;
733    unsigned short index;
734    unsigned long data;
735
736    Centaurus_write_gpio(FOUR_BYTES, CS92xx_FRM_MEMORY_INDEX, 0);
737    index = CS92xx_FRM_MEMORY_DATA;
738    for (i = 0; i < 64; i += 2) {
739        data = CentaurusFRMtable[i];
740        Centaurus_write_gpio(FOUR_BYTES, CS92xx_FRM_MEMORY_DATA, data);
741        data = CentaurusFRMtable[i + 1];
742        Centaurus_write_gpio(FOUR_BYTES, CS92xx_FRM_MEMORY_DATA, data);
743    }
744
745    /*
746     * The first FRM location (64 bits) does not program correctly.
747     * This location always reads back with the last value programmed.
748     * ie. If 32 64-bit values are programmed, location 0 reads
749     * back as the 32nd If 30 locations are programmed, location 0
750     * reads back as the 30th, etc.
751     * Fix this by re-writing location 0 after programming all 64 in
752     * the writeFRM loop in RevCFrmload() in CS9211.
753     */
754
755    Centaurus_write_gpio(FOUR_BYTES, CS92xx_FRM_MEMORY_INDEX, 0);
756    Centaurus_write_gpio(FOUR_BYTES, CS92xx_FRM_MEMORY_DATA, 0);
757    Centaurus_write_gpio(FOUR_BYTES, CS92xx_FRM_MEMORY_DATA, 0);
758}
759
760/********************************************************************
761 *
762 * void Centaurus_Enable_Power((void);
763 * Enables the power of the CX9211 using the National 97317 on
764 * a Centaurus board.
765 *
766 ********************************************************************/
767
768void
769Centaurus_Power_Up(void)
770{
771    unsigned long off_data = 0x01000000;
772
773    Centaurus_write_gpio(FOUR_BYTES, CS92xx_LCD_PWR_MAN, off_data);
774    return;
775
776}                               /* Centaurus_Disable_Power */
777
778/***********************************************************************
779 *
780 * void Centaurus_Disable_Power((void);
781 * Disables the power of the CX9211 using the National 97317
782 * on a Centaurus board.
783 *
784 **********************************************************************/
785
786void
787Centaurus_Power_Down(void)
788{
789    unsigned long off_data = 0;
790
791    Centaurus_write_gpio(FOUR_BYTES, CS92xx_LCD_PWR_MAN, off_data);
792    return;
793
794}                               /* Centaurus_Disable_Power */
795
796void
797Centaurus_9211init(Pnl_PanelStat * pstat)
798{
799    init_Centaurus_GPIO();
800    init_Centaurus_9211();
801    set_Centaurus_92xx_mode(pstat);
802    restore_Centaurus_97317_SIOC2();
803}
804
805void
806Centaurus_Save_Panel_State(void)
807{
808    /* set 9211 registers using the desired panel settings */
809
810    cs9211_regs.panel_timing1 =
811        Centaurus_read_gpio(FOUR_BYTES, CS92xx_LCD_PAN_TIMING1);
812    cs9211_regs.panel_timing2 =
813        Centaurus_read_gpio(FOUR_BYTES, CS92xx_LCD_PAN_TIMING2);
814    cs9211_regs.dither_frc_ctrl =
815        Centaurus_read_gpio(FOUR_BYTES, CS92xx_LCD_DITH_FR_CNTRL);
816    cs9211_regs.blue_lsfr_seed =
817        Centaurus_read_gpio(FOUR_BYTES, CS92xx_BLUE_LSFR_SEED);
818
819    cs9211_regs.red_green_lsfr_seed =
820        Centaurus_read_gpio(FOUR_BYTES, CS92xx_RED_GREEN_LSFR_SEED);
821    /* CentaurusProgramFRMload(); */
822
823    cs9211_regs.memory_control =
824        Centaurus_read_gpio(FOUR_BYTES, CS92xx_LCD_MEM_CNTRL);
825
826    /* Set the power register last.
827     * This will turn the panel on at the 9211.
828     */
829    cs9211_regs.power_management =
830        Centaurus_read_gpio(FOUR_BYTES, CS92xx_LCD_PWR_MAN);
831}
832
833void
834Centaurus_Restore_Panel_State(void)
835{
836
837    unsigned long off_data = 0;
838
839    /* Before restoring the 9211 registers, power off the 9211. */
840    Centaurus_write_gpio(FOUR_BYTES, CS92xx_LCD_PWR_MAN, off_data);
841
842    /* set 9211 registers using the desired panel settings */
843
844    Centaurus_write_gpio(FOUR_BYTES, CS92xx_LCD_PAN_TIMING1,
845                         cs9211_regs.panel_timing1);
846
847    Centaurus_write_gpio(FOUR_BYTES, CS92xx_LCD_PAN_TIMING2,
848                         cs9211_regs.panel_timing2);
849
850    /* load the LSFR seeds */
851
852    Centaurus_write_gpio(FOUR_BYTES, CS92xx_LCD_DITH_FR_CNTRL,
853                         cs9211_regs.dither_frc_ctrl);
854
855    Centaurus_write_gpio(FOUR_BYTES, CS92xx_BLUE_LSFR_SEED,
856                         cs9211_regs.blue_lsfr_seed);
857
858    Centaurus_write_gpio(FOUR_BYTES, CS92xx_RED_GREEN_LSFR_SEED,
859                         cs9211_regs.red_green_lsfr_seed);
860
861    Centaurus_write_gpio(FOUR_BYTES, CS92xx_LCD_MEM_CNTRL,
862                         cs9211_regs.memory_control);
863
864    /* Set the power register last. This will turn the panel on at the 9211 */
865
866    Centaurus_write_gpio(FOUR_BYTES, CS92xx_LCD_PWR_MAN,
867                         cs9211_regs.power_management);
868
869}
870