pnl_init.c revision f29dbc25
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 * intialization 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 } else if (hw_video == GFX_VID_SC1200) { 225 /* READ DISPLAY CONFIG FROM SC1200 */ 226 dcfg = READ_VID32(SC1200_DISPLAY_CONFIG); 227 228 /* SET RELEVANT FIELDS */ 229 dcfg |= (SC1200_DCFG_FP_PWR_EN | SC1200_DCFG_FP_DATA_EN); 230 /* Enable the flatpanel power and data */ 231 WRITE_VID32(SC1200_DISPLAY_CONFIG, dcfg); 232 } else if (hw_video == GFX_VID_REDCLOUD) { 233 /* READ DISPLAY CONFIG FROM REDCLOUD */ 234 dcfg = READ_VID32(RCDF_DISPLAY_CONFIG); 235 236 /* SET RELEVANT FIELDS */ 237 dcfg |= (RCDF_DCFG_FP_PWR_EN | RCDF_DCFG_FP_DATA_EN); 238 /* Enable the flatpanel power and data */ 239 WRITE_VID32(RCDF_DISPLAY_CONFIG, dcfg); 240 } 241 242} 243 244/*----------------------------------------------------------------- 245 * Pnl_PowerDown 246 * 247 * Description: This function make power down based on the 248 * hardware platforms dorado or centaraus. 249 * 250 * parameters: none. 251 * 252 * return: none. 253 *-----------------------------------------------------------------*/ 254void 255Pnl_PowerDown(void) 256{ 257 int Platform; 258 unsigned long dcfg, hw_video; 259 260 Platform = Pnl_GetPlatform(); 261 262#if PLATFORM_CENTAURUS 263 if (Platform == CENTAURUS_PLATFORM) { 264 Centaurus_Power_Down(); 265 return; 266 } 267#endif 268#if PLATFORM_DORADO 269 if (Platform == DORADO_PLATFORM) { 270 Dorado_Power_Down(); 271 return; 272 } 273#endif 274 275#if PLATFORM_GX2BASED 276 if (Platform == REDCLOUD_PLATFORM) { 277 } 278#endif 279 280 hw_video = gfx_detect_video(); 281 282 if (hw_video == GFX_VID_CS5530) { 283 /* READ DISPLAY CONFIG FROM CX5530 */ 284 dcfg = READ_VID32(CS5530_DISPLAY_CONFIG); 285 286 /* CLEAR RELEVANT FIELDS */ 287 dcfg &= ~(CS5530_DCFG_FP_PWR_EN | CS5530_DCFG_FP_DATA_EN); 288 /* Disable the flatpanel power and data */ 289 WRITE_VID32(CS5530_DISPLAY_CONFIG, dcfg); 290 } else if (hw_video == GFX_VID_SC1200) { 291 /* READ DISPLAY CONFIG FROM SC1200 */ 292 dcfg = READ_VID32(SC1200_DISPLAY_CONFIG); 293 294 /* CLEAR RELEVANT FIELDS */ 295 dcfg &= ~(SC1200_DCFG_FP_PWR_EN | SC1200_DCFG_FP_DATA_EN); 296 /* Disable the flatpanel power and data */ 297 WRITE_VID32(SC1200_DISPLAY_CONFIG, dcfg); 298 } else if (hw_video == GFX_VID_REDCLOUD) { 299 /* READ DISPLAY CONFIG FROM REDCLOUD */ 300 dcfg = READ_VID32(RCDF_DISPLAY_CONFIG); 301 302 /* CLEAR RELEVANT FIELDS */ 303 dcfg &= ~(RCDF_DCFG_FP_PWR_EN | RCDF_DCFG_FP_DATA_EN); 304 /* Disable the flatpanel power and data */ 305 WRITE_VID32(RCDF_DISPLAY_CONFIG, dcfg); 306 } 307} 308 309/*----------------------------------------------------------------- 310 * Pnl_SavePanelState 311 * 312 * Description: This function saves the panel state based on the 313 * hardware platforms dorado or centaraus. 314 * 315 * parameters: none. 316 * 317 * return: none. 318 *-----------------------------------------------------------------*/ 319void 320Pnl_SavePanelState(void) 321{ 322 int Platform; 323 324 Platform = Pnl_GetPlatform(); 325 326#if PLATFORM_CENTAURUS 327 if (Platform == CENTAURUS_PLATFORM) { 328 Centaurus_Save_Panel_State(); 329 return; 330 } 331#endif 332 333#if PLATFORM_DORADO 334 if (Platform == DORADO_PLATFORM) { 335 Dorado_Save_Panel_State(); 336 return; 337 } 338#endif 339 340#if PLATFORM_GX2BASED 341 if (Platform == REDCLOUD_PLATFORM) { 342 } 343#endif 344} 345 346/*----------------------------------------------------------------- 347 * Pnl_RestorePanelState 348 * 349 * Description: This function restore the panel state based on the 350 * hardware platforms dorado or centaraus. 351 * 352 * parameters: none. 353 * 354 * return: none. 355 *-----------------------------------------------------------------*/ 356void 357Pnl_RestorePanelState(void) 358{ 359 int Platform; 360 361 Platform = Pnl_GetPlatform(); 362#if PLATFORM_CENTAURUS 363 if (Platform == CENTAURUS_PLATFORM) { 364 Centaurus_Restore_Panel_State(); 365 return; 366 } 367#endif 368 369#if PLATFORM_DORADO 370 if (Platform == DORADO_PLATFORM) { 371 Dorado_Restore_Panel_State(); 372 return; 373 } 374#endif 375 376#if PLATFORM_GX2BASED 377 if (Platform == REDCLOUD_PLATFORM) { 378 } 379#endif 380} 381 382/*----------------------------------------------------------------- 383 * Pnl_GetPanelParam 384 * 385 * Description: This function gets the panel parameters from the 386 * hardware platforms dorado or centaraus. 387 * 388 * parameters: 389 * pParam: It specifies the elements of the panel parameter 390 * structure. 391 * 392 * return: none. 393 *-----------------------------------------------------------------*/ 394void 395Pnl_GetPanelParam(Pnl_PanelParams * pParam) 396{ 397 if (pParam->Flags & PNL_PANELPRESENT) { 398 pParam->PanelPresent = Pnl_IsPanelPresent(); 399 } 400 if (pParam->Flags & PNL_PLATFORM) { 401 pParam->Platform = Pnl_GetPlatform(); 402 } 403 if ((pParam->Flags & PNL_PANELCHIP) || (pParam->Flags & PNL_PANELSTAT)) { 404#if PLATFORM_CENTAURUS 405 if (pParam->Platform == CENTAURUS_PLATFORM) { 406 Centaurus_Get_9211_Details(pParam->Flags, pParam); 407 return; 408 } 409#endif 410 411#if PLATFORM_DORADO 412 if (pParam->Platform == DORADO_PLATFORM) { 413 Dorado_Get_9211_Details(pParam->Flags, pParam); 414 return; 415 } 416#endif 417 418#if PLATFORM_GX2BASED 419 if (pParam->Platform == REDCLOUD_PLATFORM) { 420 } 421#endif 422 423 /* if unknown platform put unknown */ 424 if (pParam->Flags & PNL_PANELCHIP) 425 pParam->PanelChip = PNL_UNKNOWN_CHIP; 426 427 if (pParam->Flags & PNL_PANELSTAT) { 428 pParam->PanelStat.XRes = 0; 429 pParam->PanelStat.YRes = 0; 430 pParam->PanelStat.Depth = 0; 431 pParam->PanelStat.MonoColor = PNL_UNKNOWN_COLOR; 432 pParam->PanelStat.Type = PNL_UNKNOWN_PANEL; 433 } 434 } 435} 436 437/*----------------------------------------------------------------- 438 * Pnl_SetPanelChip 439 * 440 * Description: This function sets the panelchip parameter of panel 441 * structure. 442 * 443 * parameters: 444 * panelChip: It specifies the panelChip value. 445 * 446 * return: none. 447 *-----------------------------------------------------------------*/ 448 449void 450Pnl_SetPanelChip(int panelChip) 451{ 452 /* To Be Implemented */ 453 sPanelParam.PanelChip = panelChip; 454 455} 456 457/*----------------------------------------------------------------- 458 * Pnl_GetPanelChip 459 * 460 * Description: This function gets the panelchip parameter of panel 461 * structure. 462 * 463 * parameters: none 464 * 465 * return: On success it returns the panelchip. 466 *-----------------------------------------------------------------*/ 467int 468Pnl_GetPanelChip(void) 469{ 470 /* To Be Implemented */ 471 return sPanelParam.PanelChip; 472} 473 474/*----------------------------------------------------------------- 475 * Pnl_InitPanel 476 * 477 * Description: This function initializes the panel with 478 * hardware platforms dorado or centaraus. 479 * 480 * parameters: 481 * pParam: It specifies the elements of the panel parameter 482 * structure. 483 * 484 * return: none. 485 *-----------------------------------------------------------------*/ 486int 487Pnl_InitPanel(Pnl_PanelParams * pParam) 488{ 489 Pnl_PanelParams *pPtr; 490 491 if (pParam == 0x0) /* NULL use the static table */ 492 pPtr = &sPanelParam; 493 else 494 pPtr = pParam; 495 496 if (!pPtr->PanelPresent) { 497 return -1; /* error */ 498 } else { 499 if ((pPtr->PanelChip < 0) || (pPtr->Platform < 0)) 500 return -1; /* error */ 501 502#if PLATFORM_DRACO 503 /* check we are init. the right one */ 504 if ((pPtr->Platform == DRACO_PLATFORM) 505 && (pPtr->PanelChip == PNL_9210)) { 506 Draco9210Init(&(pPtr->PanelStat)); 507 } 508#endif 509 510#if PLATFORM_CENTAURUS 511 /* check we are init. the right one */ 512 if (pPtr->Platform == CENTAURUS_PLATFORM) { 513 Centaurus_9211init(&(pPtr->PanelStat)); 514 } 515#endif 516 517#if PLATFORM_DORADO 518 /* check we are init. the right one */ 519 if ((pPtr->Platform == DORADO_PLATFORM) && 520 (pPtr->PanelChip == PNL_9211_C)) { 521 Dorado9211Init(&(pPtr->PanelStat)); 522 } 523#endif 524#if PLATFORM_GX2BASED 525 if (pPtr->Platform == REDCLOUD_PLATFORM) { 526 Redcloud_9211init(&(pPtr->PanelStat)); 527 } 528#endif 529 } /* else end */ 530 return 1; 531} 532