Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

202 lines
4.6 KiB

  1. /*++
  2. Copyright (c) 1994 Microsoft Corporation
  3. Module Name:
  4. opti.c
  5. Abstract:
  6. This module contains the code that contains
  7. OPTi controller(s) specific initialization and
  8. other dispatches
  9. Author:
  10. Ravisankar Pudipeddi (ravisp) 1-Nov-97
  11. Environment:
  12. Kernel mode
  13. Revision History :
  14. Neil Sandlin (neilsa) 3-Mar-99
  15. new setpower routine interface
  16. --*/
  17. #include "pch.h"
  18. VOID
  19. OptiInitialize(
  20. IN PFDO_EXTENSION FdoExtension
  21. )
  22. /*++
  23. Routine Description:
  24. Initialize OPTI cardbus controllers
  25. Arguments:
  26. FdoExtension - Pointer to the device extension for the controller FDO
  27. Return Value:
  28. None
  29. --*/
  30. {
  31. if (FdoExtension->ControllerType == PcmciaOpti82C814) {
  32. UCHAR byte;
  33. //
  34. // This fix per Opti for USB/1394 Combo hang
  35. // 5Eh[7] - enables the deadlock prevention mechanism
  36. // 5Fh[1] - reduces the retry count delay to 8 - note that 5Fh is a
  37. // WRITE-ONLY register and always reads 0. All other bits
  38. // of this register can safely be written to 0.
  39. // 5Eh[5] - enables write posting on upstream transfers
  40. // 5Eh[4] - sets the chip input buffer scaling (not related to deadlock)
  41. GetPciConfigSpace(FdoExtension, 0x5e, &byte, 1);
  42. byte |= 0xB0;
  43. SetPciConfigSpace(FdoExtension, 0x5e, &byte, 1);
  44. byte = 2;
  45. SetPciConfigSpace(FdoExtension, 0x5f, &byte, 1);
  46. }
  47. }
  48. NTSTATUS
  49. OptiSetPower(
  50. IN PSOCKET SocketPtr,
  51. IN BOOLEAN Enable,
  52. OUT PULONG pDelayTime
  53. )
  54. /*++
  55. Routine Description:
  56. Set power to the specified socket.
  57. Arguments:
  58. SocketPtr - the socket to set
  59. Enable - TRUE means to set power - FALSE is to turn it off.
  60. pDelayTime - specifies delay (msec) to occur after the current phase
  61. Return Value:
  62. STATUS_MORE_PROCESSING_REQUIRED - increment phase, perform delay, recall
  63. other status values terminate sequence
  64. --*/
  65. {
  66. NTSTATUS status;
  67. UCHAR oldPower, newPower;
  68. if (IsCardBusCardInSocket(SocketPtr)) {
  69. //
  70. // Hand over to generic power setting routine
  71. //
  72. return(CBSetPower(SocketPtr, Enable, pDelayTime));
  73. }
  74. switch(SocketPtr->PowerPhase) {
  75. case 1:
  76. //
  77. // R2 card - special handling
  78. //
  79. oldPower = PcicReadSocket(SocketPtr, PCIC_PWR_RST);
  80. //
  81. // Set new vcc
  82. // VCC always set to 5V if power is to be enabled..
  83. //
  84. newPower = (Enable ? PC_VCC_OPTI_050V : PC_VCC_OPTI_NO_CONNECT);
  85. //
  86. // Set vpp
  87. //
  88. if (Enable) {
  89. //
  90. // We - as always - set vpp to vcc..
  91. //
  92. newPower |= PC_VPP_OPTI_SETTO_VCC;
  93. } else {
  94. newPower |= PC_VPP_OPTI_NO_CONNECT;
  95. }
  96. newPower |= (oldPower & PC_OUTPUT_ENABLE);
  97. //
  98. // If Vcc is turned off, reset OUTPUT_ENABLE & AUTOPWR_ENABLE
  99. //
  100. if (!(newPower & PC_VCC_OPTI_MASK)) {
  101. newPower &= ~PC_OUTPUT_ENABLE;
  102. }
  103. status = STATUS_SUCCESS;
  104. if (newPower != oldPower) {
  105. PcicWriteSocket(SocketPtr, PCIC_PWR_RST, newPower);
  106. //
  107. // Allow ramp up.. (actually we don't need to this if
  108. // Enable was FALSE). Keep it for paranoia's sake
  109. //
  110. *pDelayTime = PCMCIA_PCIC_STALL_POWER;
  111. SocketPtr->PowerData = (ULONG) newPower;
  112. status = STATUS_MORE_PROCESSING_REQUIRED;
  113. }
  114. break;
  115. case 2:
  116. newPower = (UCHAR) SocketPtr->PowerData;
  117. if ((newPower & PC_VCC_OPTI_MASK) && !(newPower & PC_OUTPUT_ENABLE)){
  118. //
  119. // More paranoia?
  120. //
  121. newPower |= PC_OUTPUT_ENABLE;
  122. PcicWriteSocket(SocketPtr, PCIC_PWR_RST, newPower);
  123. }
  124. status = STATUS_SUCCESS;
  125. break;
  126. default:
  127. ASSERT(FALSE);
  128. status = STATUS_UNSUCCESSFUL;
  129. }
  130. return status;
  131. }
  132. BOOLEAN
  133. OptiSetZV(
  134. IN PSOCKET Socket,
  135. IN BOOLEAN Enable
  136. )
  137. {
  138. UCHAR bData;
  139. if (Enable) {
  140. bData = PcicReadSocket(Socket, PCIC_OPTI_GLOBAL_CTRL);
  141. bData |= OPTI_ZV_ENABLE;
  142. PcicWriteSocket(Socket, PCIC_OPTI_GLOBAL_CTRL, bData);
  143. } else {
  144. bData = PcicReadSocket(Socket, PCIC_OPTI_GLOBAL_CTRL);
  145. bData &= ~OPTI_ZV_ENABLE;
  146. PcicWriteSocket(Socket, PCIC_OPTI_GLOBAL_CTRL, bData);
  147. }
  148. return TRUE;
  149. }