pnl_init.c revision 79d5fcd7
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 the Geode frame buffer panel
28 *                  initialization functions.
29 *
30 * SubModule:       Geode FlatPanel library
31 * */
32
33#include "panel.h"
34#include "gfx_regs.h"
35#include "gfx_type.h"
36
37/* defaults
38 * Panel: 		Enabled
39 * Platform: 		Centaurus
40 * 92xx Chip: 		9211 Rev. A
41 * PanelType: 		DSTN
42 * XResxYRes: 		800x600
43 * Depth: 		16
44 * Mono_Color: 		Color
45 */
46static Pnl_PanelParams sPanelParam = {
47    0, 1, CENTAURUS_PLATFORM, PNL_9211_A,
48    {PNL_DSTN, 800, 600, 16, PNL_COLOR_PANEL}
49};
50
51#if PLATFORM_DRACO
52#include "drac9210.c"
53#endif
54
55#if PLATFORM_CENTAURUS
56#include "cen9211.c"
57#endif
58
59#if PLATFORM_DORADO
60#include "dora9211.c"
61#endif
62
63#if  PLATFORM_GX2BASED
64#include "gx2_9211.c"
65#endif
66#include "platform.c"
67
68/*
69 *	return -1 - UnKnown
70 *	0 - Draco has 9210
71 *	1 - Centaurus has 9211 Rev. A
72 *	2 - Dorado has 9211 Rev. C
73 */
74
75/*-----------------------------------------------------------------
76 * Pnl_SetPlatform
77 *
78 * Description:		This function sets the panel with hardware platform.
79 *
80 * parameters:
81 *		platform:	It specify the platform.
82 *
83 * return:			none.
84 *-----------------------------------------------------------------*/
85void
86Pnl_SetPlatform(int platform)
87{
88    /* To Be Implemented */
89    sPanelParam.Platform = platform;
90
91}
92
93/*-----------------------------------------------------------------
94 * Pnl_GetPlatform
95 *
96 * Description:		This function returns the panel platform.
97 *
98 * parameters:		none.
99 *
100 * return:			On success it returns the panel platform.
101 *-----------------------------------------------------------------*/
102int
103Pnl_GetPlatform(void)
104{
105    sPanelParam.Platform = Detect_Platform();
106
107    return sPanelParam.Platform;
108
109}
110
111/*-----------------------------------------------------------------
112 * Pnl_IsPanelPresent
113 *
114 * Description:		This function specifies whether the panel is prsent
115 *					or not.
116 *
117 * parameters: 		none.
118 *
119 * return: 			On success it returns an integer panel present value.
120 *-----------------------------------------------------------------*/
121int
122Pnl_IsPanelPresent(void)
123{
124    /* To Be Implemented */
125    return sPanelParam.PanelPresent;
126}
127
128/*-----------------------------------------------------------------
129 * Pnl_SetPanelPresent
130 *
131 * Description:		This function sets the panel_present parameter.
132 *
133 * parameters:
134 * 		present:	It specifies the panel present value.
135 *
136 * return:			none.
137 *-----------------------------------------------------------------*/
138void
139Pnl_SetPanelPresent(int present)
140{
141    /* To Be Implemented */
142    sPanelParam.PanelPresent = present;
143}
144
145/*-----------------------------------------------------------------
146 * Pnl_SetPanelParam
147 *
148 * Description:		This function sets the panel parameters
149 *
150 * parameters:
151 *		pParam:		It specifies the elements of the panel parameter
152 *					structure.
153 *
154 * return:	none.
155 *-----------------------------------------------------------------*/
156void
157Pnl_SetPanelParam(Pnl_PanelParams * pParam)
158{
159    if (pParam->Flags & PNL_PANELPRESENT) {
160        Pnl_SetPanelPresent(pParam->PanelPresent);
161    }
162    if (pParam->Flags & PNL_PLATFORM) {
163        Pnl_SetPlatform(pParam->Platform);
164    }
165    if (pParam->Flags & PNL_PANELCHIP) {
166        Pnl_SetPanelChip(pParam->PanelChip);
167    }
168    if (pParam->Flags & PNL_PANELSTAT) {
169        sPanelParam.PanelStat.XRes = pParam->PanelStat.XRes;
170        sPanelParam.PanelStat.YRes = pParam->PanelStat.YRes;
171        sPanelParam.PanelStat.Depth = pParam->PanelStat.Depth;
172        sPanelParam.PanelStat.MonoColor = pParam->PanelStat.MonoColor;
173        sPanelParam.PanelStat.Type = pParam->PanelStat.Type;
174    }
175}
176
177/*-----------------------------------------------------------------
178 * Pnl_PowerUp
179 *
180 * Description:		This function sets the power based on the
181 *					hardware platforms dorado or centaraus.
182 *
183 * parameters:		none.
184 *
185 * return:			none.
186 *-----------------------------------------------------------------*/
187void
188Pnl_PowerUp(void)
189{
190    int Platform;
191    unsigned long dcfg, hw_video;
192
193    Platform = Pnl_GetPlatform();
194
195#if PLATFORM_CENTAURUS
196    if (Platform == CENTAURUS_PLATFORM) {
197        Centaurus_Power_Up();
198        return;
199    }
200#endif
201
202#if PLATFORM_DORADO
203    if (Platform == DORADO_PLATFORM) {
204        Dorado_Power_Up();
205        return;
206    }
207#endif
208
209#if PLATFORM_GX2BASED
210    if (Platform == REDCLOUD_PLATFORM) {
211    }
212#endif
213
214    hw_video = gfx_detect_video();
215
216    if (hw_video == GFX_VID_CS5530) {
217        /* READ DISPLAY CONFIG FROM CX5530 */
218        dcfg = READ_VID32(CS5530_DISPLAY_CONFIG);
219
220        /* SET RELEVANT FIELDS */
221        dcfg |= (CS5530_DCFG_FP_PWR_EN | CS5530_DCFG_FP_DATA_EN);
222        /* Enable the flatpanel power and data */
223        WRITE_VID32(CS5530_DISPLAY_CONFIG, dcfg);
224    }
225    else if (hw_video == GFX_VID_SC1200) {
226        /* READ DISPLAY CONFIG FROM SC1200 */
227        dcfg = READ_VID32(SC1200_DISPLAY_CONFIG);
228
229        /* SET RELEVANT FIELDS */
230        dcfg |= (SC1200_DCFG_FP_PWR_EN | SC1200_DCFG_FP_DATA_EN);
231        /* Enable the flatpanel power and data */
232        WRITE_VID32(SC1200_DISPLAY_CONFIG, dcfg);
233    }
234    else if (hw_video == GFX_VID_REDCLOUD) {
235        /* READ DISPLAY CONFIG FROM REDCLOUD */
236        dcfg = READ_VID32(RCDF_DISPLAY_CONFIG);
237
238        /* SET RELEVANT FIELDS */
239        dcfg |= (RCDF_DCFG_FP_PWR_EN | RCDF_DCFG_FP_DATA_EN);
240        /* Enable the flatpanel power and data */
241        WRITE_VID32(RCDF_DISPLAY_CONFIG, dcfg);
242    }
243
244}
245
246/*-----------------------------------------------------------------
247 * Pnl_PowerDown
248 *
249 * Description:		This function make power down based on the
250 *					hardware platforms dorado or centaraus.
251 *
252 * parameters:		none.
253 *
254 * return:			none.
255 *-----------------------------------------------------------------*/
256void
257Pnl_PowerDown(void)
258{
259    int Platform;
260    unsigned long dcfg, hw_video;
261
262    Platform = Pnl_GetPlatform();
263
264#if PLATFORM_CENTAURUS
265    if (Platform == CENTAURUS_PLATFORM) {
266        Centaurus_Power_Down();
267        return;
268    }
269#endif
270#if PLATFORM_DORADO
271    if (Platform == DORADO_PLATFORM) {
272        Dorado_Power_Down();
273        return;
274    }
275#endif
276
277#if PLATFORM_GX2BASED
278    if (Platform == REDCLOUD_PLATFORM) {
279    }
280#endif
281
282    hw_video = gfx_detect_video();
283
284    if (hw_video == GFX_VID_CS5530) {
285        /* READ DISPLAY CONFIG FROM CX5530 */
286        dcfg = READ_VID32(CS5530_DISPLAY_CONFIG);
287
288        /* CLEAR RELEVANT FIELDS */
289        dcfg &= ~(CS5530_DCFG_FP_PWR_EN | CS5530_DCFG_FP_DATA_EN);
290        /* Disable the flatpanel power and data */
291        WRITE_VID32(CS5530_DISPLAY_CONFIG, dcfg);
292    }
293    else if (hw_video == GFX_VID_SC1200) {
294        /* READ DISPLAY CONFIG FROM SC1200 */
295        dcfg = READ_VID32(SC1200_DISPLAY_CONFIG);
296
297        /* CLEAR RELEVANT FIELDS */
298        dcfg &= ~(SC1200_DCFG_FP_PWR_EN | SC1200_DCFG_FP_DATA_EN);
299        /* Disable the flatpanel power and data */
300        WRITE_VID32(SC1200_DISPLAY_CONFIG, dcfg);
301    }
302    else if (hw_video == GFX_VID_REDCLOUD) {
303        /* READ DISPLAY CONFIG FROM REDCLOUD */
304        dcfg = READ_VID32(RCDF_DISPLAY_CONFIG);
305
306        /* CLEAR RELEVANT FIELDS */
307        dcfg &= ~(RCDF_DCFG_FP_PWR_EN | RCDF_DCFG_FP_DATA_EN);
308        /* Disable the flatpanel power and data */
309        WRITE_VID32(RCDF_DISPLAY_CONFIG, dcfg);
310    }
311}
312
313/*-----------------------------------------------------------------
314 * Pnl_SavePanelState
315 *
316 * Description:		This function saves the panel state based on the
317 *					hardware platforms dorado or centaraus.
318 *
319 * parameters:		none.
320 *
321 * return:			none.
322 *-----------------------------------------------------------------*/
323void
324Pnl_SavePanelState(void)
325{
326    int Platform;
327
328    Platform = Pnl_GetPlatform();
329
330#if PLATFORM_CENTAURUS
331    if (Platform == CENTAURUS_PLATFORM) {
332        Centaurus_Save_Panel_State();
333        return;
334    }
335#endif
336
337#if PLATFORM_DORADO
338    if (Platform == DORADO_PLATFORM) {
339        Dorado_Save_Panel_State();
340        return;
341    }
342#endif
343
344#if PLATFORM_GX2BASED
345    if (Platform == REDCLOUD_PLATFORM) {
346    }
347#endif
348}
349
350/*-----------------------------------------------------------------
351 * Pnl_RestorePanelState
352 *
353 * Description:		This function restore the panel state based on the
354 *					hardware platforms dorado or centaraus.
355 *
356 * parameters:		none.
357 *
358 * return:			none.
359 *-----------------------------------------------------------------*/
360void
361Pnl_RestorePanelState(void)
362{
363    int Platform;
364
365    Platform = Pnl_GetPlatform();
366#if PLATFORM_CENTAURUS
367    if (Platform == CENTAURUS_PLATFORM) {
368        Centaurus_Restore_Panel_State();
369        return;
370    }
371#endif
372
373#if PLATFORM_DORADO
374    if (Platform == DORADO_PLATFORM) {
375        Dorado_Restore_Panel_State();
376        return;
377    }
378#endif
379
380#if PLATFORM_GX2BASED
381    if (Platform == REDCLOUD_PLATFORM) {
382    }
383#endif
384}
385
386/*-----------------------------------------------------------------
387 * Pnl_GetPanelParam
388 *
389 * Description:		This function gets the panel parameters from the
390 *					hardware platforms dorado or centaraus.
391 *
392 * parameters:
393 * 		pParam:		It specifies the elements of the panel parameter
394 *					structure.
395 *
396 * return:			none.
397 *-----------------------------------------------------------------*/
398void
399Pnl_GetPanelParam(Pnl_PanelParams * pParam)
400{
401    if (pParam->Flags & PNL_PANELPRESENT) {
402        pParam->PanelPresent = Pnl_IsPanelPresent();
403    }
404    if (pParam->Flags & PNL_PLATFORM) {
405        pParam->Platform = Pnl_GetPlatform();
406    }
407    if ((pParam->Flags & PNL_PANELCHIP) || (pParam->Flags & PNL_PANELSTAT)) {
408#if PLATFORM_CENTAURUS
409        if (pParam->Platform == CENTAURUS_PLATFORM) {
410            Centaurus_Get_9211_Details(pParam->Flags, pParam);
411            return;
412        }
413#endif
414
415#if PLATFORM_DORADO
416        if (pParam->Platform == DORADO_PLATFORM) {
417            Dorado_Get_9211_Details(pParam->Flags, pParam);
418            return;
419        }
420#endif
421
422#if PLATFORM_GX2BASED
423        if (pParam->Platform == REDCLOUD_PLATFORM) {
424        }
425#endif
426
427        /* if unknown platform put unknown */
428        if (pParam->Flags & PNL_PANELCHIP)
429            pParam->PanelChip = PNL_UNKNOWN_CHIP;
430
431        if (pParam->Flags & PNL_PANELSTAT) {
432            pParam->PanelStat.XRes = 0;
433            pParam->PanelStat.YRes = 0;
434            pParam->PanelStat.Depth = 0;
435            pParam->PanelStat.MonoColor = PNL_UNKNOWN_COLOR;
436            pParam->PanelStat.Type = PNL_UNKNOWN_PANEL;
437        }
438    }
439}
440
441/*-----------------------------------------------------------------
442 * Pnl_SetPanelChip
443 *
444 * Description:		This function sets the panelchip parameter of panel
445 *					structure.
446 *
447 * parameters:
448 *   	panelChip:	It specifies the panelChip value.
449 *
450 * return:			none.
451 *-----------------------------------------------------------------*/
452
453void
454Pnl_SetPanelChip(int panelChip)
455{
456    /* To Be Implemented */
457    sPanelParam.PanelChip = panelChip;
458
459}
460
461/*-----------------------------------------------------------------
462 * Pnl_GetPanelChip
463 *
464 * Description:		This function gets the panelchip parameter of panel
465 *					structure.
466 *
467 * parameters:		none
468 *
469 * return:			On success it returns the panelchip.
470 *-----------------------------------------------------------------*/
471int
472Pnl_GetPanelChip(void)
473{
474    /* To Be Implemented */
475    return sPanelParam.PanelChip;
476}
477
478/*-----------------------------------------------------------------
479 * Pnl_InitPanel
480 *
481 * Description:		This function initializes the panel with
482 *					hardware platforms dorado or centaraus.
483 *
484 * parameters:
485 * 		pParam:		It specifies the elements of the panel parameter
486 *					structure.
487 *
488 * return:			none.
489 *-----------------------------------------------------------------*/
490int
491Pnl_InitPanel(Pnl_PanelParams * pParam)
492{
493    Pnl_PanelParams *pPtr;
494
495    if (pParam == 0x0)          /* NULL  use the static table */
496        pPtr = &sPanelParam;
497    else
498        pPtr = pParam;
499
500    if (!pPtr->PanelPresent) {
501        return -1;              /* error */
502    }
503    else {
504        if ((pPtr->PanelChip < 0) || (pPtr->Platform < 0))
505            return -1;          /* error */
506
507#if PLATFORM_DRACO
508        /* check we are init. the right one */
509        if ((pPtr->Platform == DRACO_PLATFORM)
510            && (pPtr->PanelChip == PNL_9210)) {
511            Draco9210Init(&(pPtr->PanelStat));
512        }
513#endif
514
515#if PLATFORM_CENTAURUS
516        /* check we are init. the right one */
517        if (pPtr->Platform == CENTAURUS_PLATFORM) {
518            Centaurus_9211init(&(pPtr->PanelStat));
519        }
520#endif
521
522#if PLATFORM_DORADO
523        /* check we are init. the right one */
524        if ((pPtr->Platform == DORADO_PLATFORM) &&
525            (pPtr->PanelChip == PNL_9211_C)) {
526            Dorado9211Init(&(pPtr->PanelStat));
527        }
528#endif
529#if PLATFORM_GX2BASED
530        if (pPtr->Platform == REDCLOUD_PLATFORM) {
531            Redcloud_9211init(&(pPtr->PanelStat));
532        }
533#endif
534    }                           /* else  end */
535    return 1;
536}
537