1/* $XFree86$ */ 2/* 3 * $Workfile: pnl_init.c $ 4 * $Revision: 1.1.1.1 $ 5 * 6 * File Contents: This file contains the Geode frame buffer panel 7 * intialization functions. 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 "panel.h" 143#include "gfx_regs.h" 144#include "gfx_type.h" 145 146/* defaults 147Panel : Enabled 148Platform : Centaurus 14992xx Chip : 9211 Rev. A 150PanelType : DSTN 151XResxYRes : 800x600 152Depth : 16 153Mono_Color : Color 154*/ 155static Pnl_PanelParams sPanelParam = { 156 0, 1, CENTAURUS_PLATFORM, PNL_9211_A, 157 {PNL_DSTN, 800, 600, 16, PNL_COLOR_PANEL} 158}; 159 160#if PLATFORM_DRACO 161#include "drac9210.c" 162#endif 163 164#if PLATFORM_CENTAURUS 165#include "cen9211.c" 166#endif 167 168#if PLATFORM_DORADO 169#include "dora9211.c" 170#endif 171 172#if PLATFORM_GX2BASED 173#include "gx2_9211.c" 174#endif 175#include "platform.c" 176 177/* 178 * return -1 - UnKnown 179 * 0 - Draco has 9210 180 * 1 - Centaurus has 9211 Rev. A 181 * 2 - Dorado has 9211 Rev. C 182 */ 183 184/*----------------------------------------------------------------- 185 * Pnl_SetPlatform 186 * 187 * Description: This function sets the panel with hardware platform. 188 * parameters: 189 * platform: It specify the platform. 190 * return: none. 191 *-----------------------------------------------------------------*/ 192void 193Pnl_SetPlatform(int platform) 194{ 195 /* To Be Implemented */ 196 sPanelParam.Platform = platform; 197 198} 199 200/*----------------------------------------------------------------- 201 * Pnl_GetPlatform 202 * 203 * Description: This function returns the panel platform. 204 * parameters: none. 205 * return: On success it returns the panel platform. 206 *-----------------------------------------------------------------*/ 207int 208Pnl_GetPlatform(void) 209{ 210 sPanelParam.Platform = Detect_Platform(); 211 212 return sPanelParam.Platform; 213 214} 215 216/*----------------------------------------------------------------- 217 * Pnl_IsPanelPresent 218 * 219 * Description: This function specifies whether the panel is prsent 220 * or not. 221 * parameters: none. 222 * return: On success it returns an integer panel present value. 223 *-----------------------------------------------------------------*/ 224int 225Pnl_IsPanelPresent(void) 226{ 227 /* To Be Implemented */ 228 return sPanelParam.PanelPresent; 229} 230 231/*----------------------------------------------------------------- 232 * Pnl_SetPanelPresent 233 * 234 * Description: This function sets the panel_present parameter. 235 * parameters: 236 * present: It specifies the panel present value. 237 * return: none. 238 *-----------------------------------------------------------------*/ 239void 240Pnl_SetPanelPresent(int present) 241{ 242 /* To Be Implemented */ 243 sPanelParam.PanelPresent = present; 244} 245 246/*----------------------------------------------------------------- 247 * Pnl_SetPanelParam 248 * 249 * Description: This function sets the panel parameters 250 * parameters: 251 * pParam: It specifies the elements of the panel parameter 252 * structure. 253 * return: none. 254 *-----------------------------------------------------------------*/ 255void 256Pnl_SetPanelParam(PPnl_PanelParams pParam) 257{ 258 if (pParam->Flags & PNL_PANELPRESENT) { 259 Pnl_SetPanelPresent(pParam->PanelPresent); 260 } 261 if (pParam->Flags & PNL_PLATFORM) { 262 Pnl_SetPlatform(pParam->Platform); 263 } 264 if (pParam->Flags & PNL_PANELCHIP) { 265 Pnl_SetPanelChip(pParam->PanelChip); 266 } 267 if (pParam->Flags & PNL_PANELSTAT) { 268 sPanelParam.PanelStat.XRes = pParam->PanelStat.XRes; 269 sPanelParam.PanelStat.YRes = pParam->PanelStat.YRes; 270 sPanelParam.PanelStat.Depth = pParam->PanelStat.Depth; 271 sPanelParam.PanelStat.MonoColor = pParam->PanelStat.MonoColor; 272 sPanelParam.PanelStat.Type = pParam->PanelStat.Type; 273 } 274} 275 276/*----------------------------------------------------------------- 277 * Pnl_PowerUp 278 * 279 * Description: This function sets the power based on the 280 * hardware platforms dorado or centaraus. 281 * parameters: none. 282 * return: none. 283 *-----------------------------------------------------------------*/ 284void 285Pnl_PowerUp(void) 286{ 287 int Platform; 288 unsigned long dcfg, hw_video; 289 290 Platform = Pnl_GetPlatform(); 291 292#if PLATFORM_CENTAURUS 293 if (Platform == CENTAURUS_PLATFORM) { 294 Centaurus_Power_Up(); 295 return; 296 } 297#endif 298 299#if PLATFORM_DORADO 300 if (Platform == DORADO_PLATFORM) { 301 Dorado_Power_Up(); 302 return; 303 } 304#endif 305 306#if PLATFORM_GX2BASED 307 if (Platform == REDCLOUD_PLATFORM) { 308 } 309#endif 310 311 hw_video = gfx_detect_video(); 312 313 if (hw_video == GFX_VID_CS5530) { 314 /* READ DISPLAY CONFIG FROM CX5530 */ 315 dcfg = READ_VID32(CS5530_DISPLAY_CONFIG); 316 317 /* SET RELEVANT FIELDS */ 318 dcfg |= (CS5530_DCFG_FP_PWR_EN | CS5530_DCFG_FP_DATA_EN); 319 /* Enable the flatpanel power and data */ 320 WRITE_VID32(CS5530_DISPLAY_CONFIG, dcfg); 321 } else if (hw_video == GFX_VID_SC1200) { 322 /* READ DISPLAY CONFIG FROM SC1200 */ 323 dcfg = READ_VID32(SC1200_DISPLAY_CONFIG); 324 325 /* SET RELEVANT FIELDS */ 326 dcfg |= (SC1200_DCFG_FP_PWR_EN | SC1200_DCFG_FP_DATA_EN); 327 /* Enable the flatpanel power and data */ 328 WRITE_VID32(SC1200_DISPLAY_CONFIG, dcfg); 329 } else if (hw_video == GFX_VID_REDCLOUD) { 330 /* READ DISPLAY CONFIG FROM REDCLOUD */ 331 dcfg = READ_VID32(RCDF_DISPLAY_CONFIG); 332 333 /* SET RELEVANT FIELDS */ 334 dcfg |= (RCDF_DCFG_FP_PWR_EN | RCDF_DCFG_FP_DATA_EN); 335 /* Enable the flatpanel power and data */ 336 WRITE_VID32(RCDF_DISPLAY_CONFIG, dcfg); 337 } 338 339} 340 341/*----------------------------------------------------------------- 342 * Pnl_PowerDown 343 * 344 * Description: This function make power down based on the 345 * hardware platforms dorado or centaraus. 346 * parameters: none. 347 * return: none. 348 *-----------------------------------------------------------------*/ 349void 350Pnl_PowerDown(void) 351{ 352 int Platform; 353 unsigned long dcfg, hw_video; 354 355 Platform = Pnl_GetPlatform(); 356 357#if PLATFORM_CENTAURUS 358 if (Platform == CENTAURUS_PLATFORM) { 359 Centaurus_Power_Down(); 360 return; 361 } 362#endif 363#if PLATFORM_DORADO 364 if (Platform == DORADO_PLATFORM) { 365 Dorado_Power_Down(); 366 return; 367 } 368#endif 369 370#if PLATFORM_GX2BASED 371 if (Platform == REDCLOUD_PLATFORM) { 372 } 373#endif 374 375 hw_video = gfx_detect_video(); 376 377 if (hw_video == GFX_VID_CS5530) { 378 /* READ DISPLAY CONFIG FROM CX5530 */ 379 dcfg = READ_VID32(CS5530_DISPLAY_CONFIG); 380 381 /* CLEAR RELEVANT FIELDS */ 382 dcfg &= ~(CS5530_DCFG_FP_PWR_EN | CS5530_DCFG_FP_DATA_EN); 383 /* Disable the flatpanel power and data */ 384 WRITE_VID32(CS5530_DISPLAY_CONFIG, dcfg); 385 } else if (hw_video == GFX_VID_SC1200) { 386 /* READ DISPLAY CONFIG FROM SC1200 */ 387 dcfg = READ_VID32(SC1200_DISPLAY_CONFIG); 388 389 /* CLEAR RELEVANT FIELDS */ 390 dcfg &= ~(SC1200_DCFG_FP_PWR_EN | SC1200_DCFG_FP_DATA_EN); 391 /* Disable the flatpanel power and data */ 392 WRITE_VID32(SC1200_DISPLAY_CONFIG, dcfg); 393 } else if (hw_video == GFX_VID_REDCLOUD) { 394 /* READ DISPLAY CONFIG FROM REDCLOUD */ 395 dcfg = READ_VID32(RCDF_DISPLAY_CONFIG); 396 397 /* CLEAR RELEVANT FIELDS */ 398 dcfg &= ~(RCDF_DCFG_FP_PWR_EN | RCDF_DCFG_FP_DATA_EN); 399 /* Disable the flatpanel power and data */ 400 WRITE_VID32(RCDF_DISPLAY_CONFIG, dcfg); 401 } 402} 403 404/*----------------------------------------------------------------- 405 * Pnl_SavePanelState 406 * 407 * Description: This function saves the panel state based on the 408 * hardware platforms dorado or centaraus. 409 * parameters: none. 410 * return: none. 411 *-----------------------------------------------------------------*/ 412void 413Pnl_SavePanelState(void) 414{ 415 int Platform; 416 417 Platform = Pnl_GetPlatform(); 418 419#if PLATFORM_CENTAURUS 420 if (Platform == CENTAURUS_PLATFORM) { 421 Centaurus_Save_Panel_State(); 422 return; 423 } 424#endif 425 426#if PLATFORM_DORADO 427 if (Platform == DORADO_PLATFORM) { 428 Dorado_Save_Panel_State(); 429 return; 430 } 431#endif 432 433#if PLATFORM_GX2BASED 434 if (Platform == REDCLOUD_PLATFORM) { 435 } 436#endif 437} 438 439/*----------------------------------------------------------------- 440 * Pnl_RestorePanelState 441 * 442 * Description: This function restore the panel state based on the 443 * hardware platforms dorado or centaraus. 444 * parameters: none. 445 * return: none. 446 *-----------------------------------------------------------------*/ 447void 448Pnl_RestorePanelState(void) 449{ 450 int Platform; 451 452 Platform = Pnl_GetPlatform(); 453#if PLATFORM_CENTAURUS 454 if (Platform == CENTAURUS_PLATFORM) { 455 Centaurus_Restore_Panel_State(); 456 return; 457 } 458#endif 459 460#if PLATFORM_DORADO 461 if (Platform == DORADO_PLATFORM) { 462 Dorado_Restore_Panel_State(); 463 return; 464 } 465#endif 466 467#if PLATFORM_GX2BASED 468 if (Platform == REDCLOUD_PLATFORM) { 469 } 470#endif 471} 472 473/*----------------------------------------------------------------- 474 * Pnl_GetPanelParam 475 * 476 * Description: This function gets the panel parameters from the 477 * hardware platforms dorado or centaraus. 478 * parameters: 479 * pParam: It specifies the elements of the panel parameter 480 * structure. 481 * return: none. 482 *-----------------------------------------------------------------*/ 483void 484Pnl_GetPanelParam(PPnl_PanelParams pParam) 485{ 486 if (pParam->Flags & PNL_PANELPRESENT) { 487 pParam->PanelPresent = Pnl_IsPanelPresent(); 488 } 489 if (pParam->Flags & PNL_PLATFORM) { 490 pParam->Platform = Pnl_GetPlatform(); 491 } 492 if ((pParam->Flags & PNL_PANELCHIP) || (pParam->Flags & PNL_PANELSTAT)) { 493#if PLATFORM_CENTAURUS 494 if (pParam->Platform == CENTAURUS_PLATFORM) { 495 Centaurus_Get_9211_Details(pParam->Flags, pParam); 496 return; 497 } 498#endif 499 500#if PLATFORM_DORADO 501 if (pParam->Platform == DORADO_PLATFORM) { 502 Dorado_Get_9211_Details(pParam->Flags, pParam); 503 return; 504 } 505#endif 506 507#if PLATFORM_GX2BASED 508 if (pParam->Platform == REDCLOUD_PLATFORM) { 509 } 510#endif 511 512 /* if unknown platform put unknown */ 513 if (pParam->Flags & PNL_PANELCHIP) 514 pParam->PanelChip = PNL_UNKNOWN_CHIP; 515 516 if (pParam->Flags & PNL_PANELSTAT) { 517 pParam->PanelStat.XRes = 0; 518 pParam->PanelStat.YRes = 0; 519 pParam->PanelStat.Depth = 0; 520 pParam->PanelStat.MonoColor = PNL_UNKNOWN_COLOR; 521 pParam->PanelStat.Type = PNL_UNKNOWN_PANEL; 522 } 523 } 524} 525 526/*----------------------------------------------------------------- 527 * Pnl_SetPanelChip 528 * 529 * Description: This function sets the panelchip parameter of panel 530 * structure. 531 * parameters: 532 * panelChip: It specifies the panelChip value. 533 * return: none. 534 *-----------------------------------------------------------------*/ 535 536void 537Pnl_SetPanelChip(int panelChip) 538{ 539 /* To Be Implemented */ 540 sPanelParam.PanelChip = panelChip; 541 542} 543 544/*----------------------------------------------------------------- 545 * Pnl_GetPanelChip 546 * 547 * Description: This function gets the panelchip parameter of panel 548 * structure. 549 * parameters: 550 * return: On success it returns the panelchip. 551 *-----------------------------------------------------------------*/ 552int 553Pnl_GetPanelChip(void) 554{ 555 /* To Be Implemented */ 556 return sPanelParam.PanelChip; 557} 558 559/*----------------------------------------------------------------- 560 * Pnl_InitPanel 561 * 562 * Description: This function initializes the panel with 563 * hardware platforms dorado or centaraus. 564 * parameters: 565 * pParam: It specifies the elements of the panel parameter 566 * structure. 567 * return: none. 568 *-----------------------------------------------------------------*/ 569int 570Pnl_InitPanel(PPnl_PanelParams pParam) 571{ 572 PPnl_PanelParams pPtr; 573 574 if (pParam == 0x0) /* NULL use the static table */ 575 pPtr = &sPanelParam; 576 else 577 pPtr = pParam; 578 579 if (!pPtr->PanelPresent) { 580 return -1; /* error */ 581 } else { 582 if ((pPtr->PanelChip < 0) || (pPtr->Platform < 0)) 583 return -1; /* error */ 584 585#if PLATFORM_DRACO 586 /* check we are init. the right one */ 587 if ((pPtr->Platform == DRACO_PLATFORM) && (pPtr->PanelChip == PNL_9210)) { 588 Draco9210Init(&(pPtr->PanelStat)); 589 } 590#endif 591 592#if PLATFORM_CENTAURUS 593 /* check we are init. the right one */ 594 if (pPtr->Platform == CENTAURUS_PLATFORM) { 595 Centaurus_9211init(&(pPtr->PanelStat)); 596 } 597#endif 598 599#if PLATFORM_DORADO 600 /* check we are init. the right one */ 601 if ((pPtr->Platform == DORADO_PLATFORM) && 602 (pPtr->PanelChip == PNL_9211_C)) { 603 Dorado9211Init(&(pPtr->PanelStat)); 604 } 605#endif 606#if PLATFORM_GX2BASED 607 if (pPtr->Platform == REDCLOUD_PLATFORM) { 608 Redcloud_9211init(&(pPtr->PanelStat)); 609 } 610#endif 611 } /* else end */ 612 return 1; 613} 614