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.

233 lines
5.9 KiB

  1. /*++
  2. Copyright (c) 1994 Microsoft Corporation
  3. Module Name:
  4. cl.c
  5. Abstract:
  6. This module contains the code that contains
  7. Cirrus Logic controller 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. CLInitialize(IN PFDO_EXTENSION FdoExtension)
  20. /*++
  21. Routine Description:
  22. Initialize Cirrus Logic cardbus controllers
  23. Arguments:
  24. FdoExtension - Pointer to the device extension for the controller FDO
  25. Return Value:
  26. None
  27. --*/
  28. {
  29. UCHAR byte, revisionID;
  30. USHORT word;
  31. byte = PcicReadSocket(FdoExtension->SocketList,
  32. PCIC_CL_MISC_CTRL3);
  33. if ((FdoExtension->ControllerType == PcmciaCLPD6832) &&
  34. ((byte & CL_MC3_INTMODE_MASK) == CL_MC3_INTMODE_EXTHW)) {
  35. FdoExtension->LegacyIrqMask = 0xd8b8; //3,4,5,7,11,12,14,15
  36. }
  37. GetPciConfigSpace(FdoExtension, CFGSPACE_REV_ID, &revisionID, 1);
  38. if (FdoExtension->ControllerType == PcmciaCLPD6832) {
  39. //disable CSC IRQ routing (use PCI interrupt for CSC)
  40. GetPciConfigSpace(FdoExtension, CFGSPACE_BRIDGE_CTRL, &word, 2);
  41. word &= ~BCTRL_CL_CSCIRQROUTING_ENABLE;
  42. SetPciConfigSpace(FdoExtension, CFGSPACE_BRIDGE_CTRL, &word, 2);
  43. }
  44. else {
  45. //disable CSC IRQ routing (use PCI interrupt for CSC)
  46. GetPciConfigSpace(FdoExtension, CFGSPACE_CL_CFGMISC1, &byte, 1);
  47. byte &= ~CL_CFGMISC1_ISACSC;
  48. SetPciConfigSpace(FdoExtension, CFGSPACE_CL_CFGMISC1, &byte, 1);
  49. }
  50. //enable speaker
  51. byte = PcicReadSocket(FdoExtension->SocketList, PCIC_CL_MISC_CTRL1);
  52. byte |= CL_MC1_SPKR_ENABLE;
  53. PcicWriteSocket(FdoExtension->SocketList, PCIC_CL_MISC_CTRL1, byte);
  54. byte = PcicReadSocket(FdoExtension->SocketList, PCIC_CL_DEV_IMP_C);
  55. if (byte & (CL_IMPC_ZVP_A | CL_IMPC_ZVP_B)) {
  56. //enable multimedia support (i.e. ZV)
  57. byte = PcicReadSocket(FdoExtension->SocketList,PCIC_CL_MISC_CTRL3);
  58. byte |= CL_MC3_MM_ARM;
  59. PcicWriteSocket(FdoExtension->SocketList, PCIC_CL_MISC_CTRL3,byte);
  60. }
  61. }
  62. NTSTATUS
  63. CLSetPower(
  64. IN PSOCKET SocketPtr,
  65. IN BOOLEAN Enable,
  66. OUT PULONG pDelayTime
  67. )
  68. /*++
  69. Routine Description:
  70. Set power to the specified socket.
  71. Arguments:
  72. SocketPtr - the socket to set
  73. Enable - TRUE means to set power - FALSE is to turn it off.
  74. pDelayTime - specifies delay (msec) to occur after the current phase
  75. Return Value:
  76. STATUS_MORE_PROCESSING_REQUIRED - increment phase, perform delay, recall
  77. other status values terminate sequence
  78. --*/
  79. {
  80. NTSTATUS status;
  81. UCHAR oldPower, newPower, oldMiscCtrl, newMiscCtrl;
  82. if (IsCardBusCardInSocket(SocketPtr)) {
  83. //
  84. // Hand over to generic power setting routine
  85. //
  86. return(CBSetPower(SocketPtr, Enable, pDelayTime));
  87. }
  88. switch(SocketPtr->PowerPhase) {
  89. case 1:
  90. //
  91. // R2 card - special handling
  92. //
  93. oldPower = PcicReadSocket(SocketPtr, PCIC_PWR_RST);
  94. oldMiscCtrl = PcicReadSocket(SocketPtr, PCIC_CL_MISC_CTRL1);
  95. //
  96. // Set new vcc
  97. //
  98. newPower = (Enable ? PC_CARDPWR_ENABLE: 0);
  99. //
  100. // Since we always set 5V for R2 cards, we let MISC control be 0
  101. // other wise it should be CL_MC1_VCC_3V if the vcc was 3.3V
  102. //
  103. newMiscCtrl = 0;
  104. //
  105. // Set vpp
  106. //
  107. if (Enable) {
  108. //
  109. // We - as always - set vpp to vcc..
  110. //
  111. newPower |= PC_VPP_SETTO_VCC;
  112. }
  113. //
  114. // Don't nuke the non-power related bits in the register..
  115. //
  116. newPower |= (oldPower & PC_PWRON_BITS);
  117. newMiscCtrl |= (oldMiscCtrl & ~CL_MC1_VCC_33V);
  118. //
  119. // If Vcc is turned off, reset OUTPUT_ENABLE & AUTOPWR_ENABLE
  120. //
  121. if (!(newPower & PC_CARDPWR_ENABLE)) {
  122. newPower &= ~PC_PWRON_BITS;
  123. }
  124. //
  125. // Only set power if nothing's changed..
  126. //
  127. status = STATUS_SUCCESS;
  128. if ((newPower != oldPower) || (newMiscCtrl != oldMiscCtrl)) {
  129. PcicWriteSocket(SocketPtr, PCIC_PWR_RST, newPower);
  130. PcicWriteSocket(SocketPtr, PCIC_CL_MISC_CTRL1, newMiscCtrl);
  131. //
  132. // Allow ramp up.. (actually we don't need to this if
  133. // Enable was FALSE). Keep it for paranoia's sake
  134. //
  135. *pDelayTime = PCMCIA_PCIC_STALL_POWER;
  136. SocketPtr->PowerData = (ULONG) newPower;
  137. status = STATUS_MORE_PROCESSING_REQUIRED;
  138. }
  139. break;
  140. case 2:
  141. newPower = (UCHAR) SocketPtr->PowerData;
  142. if ((newPower & PC_CARDPWR_ENABLE) &&
  143. ((newPower & PC_PWRON_BITS) != PC_PWRON_BITS)) {
  144. //
  145. // More paranoia?
  146. //
  147. newPower |= PC_PWRON_BITS;
  148. PcicWriteSocket(SocketPtr, PCIC_PWR_RST, newPower);
  149. }
  150. status = STATUS_SUCCESS;
  151. break;
  152. default:
  153. ASSERT(FALSE);
  154. status = STATUS_UNSUCCESSFUL;
  155. }
  156. return status;
  157. }
  158. BOOLEAN
  159. CLSetZV(
  160. IN PSOCKET Socket,
  161. IN BOOLEAN Enable
  162. )
  163. {
  164. UCHAR bData;
  165. if (Enable) {
  166. bData = PcicReadSocket(Socket, PCIC_CL_MISC_CTRL1);
  167. bData |= CL_MC1_MM_ENABLE;
  168. bData &= ~CL_MC1_SPKR_ENABLE;
  169. PcicWriteSocket(Socket, PCIC_CL_MISC_CTRL1, bData);
  170. } else {
  171. bData = PcicReadSocket(Socket, PCIC_CL_MISC_CTRL1);
  172. bData &= ~CL_MC1_MM_ENABLE;
  173. bData |= CL_MC1_SPKR_ENABLE;
  174. PcicWriteSocket(Socket, PCIC_CL_MISC_CTRL1, bData);
  175. }
  176. return TRUE;
  177. }