Source code of Windows XP (NT5)
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.

269 lines
5.6 KiB

  1. /*++
  2. Copyright (c) 1997-2000 Microsoft Corporation
  3. Module Name:
  4. topic.c
  5. Abstract:
  6. This module contains the code that contains
  7. Toshiba topic cardbus controller specific initialization
  8. and other dispatches
  9. Author:
  10. Ravisankar Pudipeddi (ravisp) 1-Nov-97
  11. Neil Sandlin (neilsa) 1-Jun-1999
  12. Environment:
  13. Kernel mode
  14. Revision History :
  15. Neil Sandlin (neilsa) 3-Mar-99
  16. new setpower routine interface
  17. --*/
  18. #include "pch.h"
  19. VOID
  20. TopicInitialize(
  21. IN PFDO_EXTENSION FdoExtension
  22. )
  23. /*++
  24. Routine Description:
  25. Initialize Toshiba Topic cardbus controllers
  26. Arguments:
  27. FdoExtension - Pointer to the device extension for the controller FDO
  28. Return Value:
  29. None
  30. --*/
  31. {
  32. UCHAR byte;
  33. USHORT word;
  34. if (FdoExtension->ControllerType == PcmciaTopic95) {
  35. //
  36. // 480CDT in a dock needs this for socket registers to be visible.
  37. // It should be on all the time anyway.
  38. //
  39. GetPciConfigSpace(FdoExtension, CFGSPACE_TO_CD_CTRL, &byte, 1);
  40. byte |= CDCTRL_PCCARD_16_32;
  41. SetPciConfigSpace(FdoExtension, CFGSPACE_TO_CD_CTRL, &byte, 1);
  42. }
  43. //enable 3.3V capable
  44. byte = PcicReadSocket(FdoExtension->SocketList, PCIC_TO_FUNC_CTRL) | TO_FCTRL_CARDPWR_ENABLE;
  45. PcicWriteSocket(FdoExtension->SocketList,
  46. PCIC_TO_FUNC_CTRL,
  47. byte);
  48. //
  49. // initialize IRQ routing to ISA
  50. //
  51. GetPciConfigSpace(FdoExtension, CFGSPACE_BRIDGE_CTRL, &word, 2);
  52. word |= BCTRL_IRQROUTING_ENABLE;
  53. SetPciConfigSpace(FdoExtension, CFGSPACE_BRIDGE_CTRL, &word, 2);
  54. }
  55. NTSTATUS
  56. TopicSetPower(
  57. IN PSOCKET Socket,
  58. IN BOOLEAN Enable,
  59. OUT PULONG pDelayTime
  60. )
  61. /*++
  62. Routine Description:
  63. Set power to the specified socket.
  64. Arguments:
  65. Socket - the socket to set
  66. Enable - TRUE means to set power - FALSE is to turn it off.
  67. pDelayTime - specifies delay (msec) to occur after the current phase
  68. Return Value:
  69. STATUS_MORE_PROCESSING_REQUIRED - increment phase, perform delay, recall
  70. other status values terminate sequence
  71. --*/
  72. {
  73. NTSTATUS status;
  74. UCHAR oldPower, newPower;
  75. if (IsCardBusCardInSocket(Socket)) {
  76. //
  77. // Hand over to generic power setting routine
  78. //
  79. return(CBSetPower(Socket, Enable, pDelayTime));
  80. }
  81. switch(Socket->PowerPhase) {
  82. case 1:
  83. //
  84. // R2 card - special handling
  85. //
  86. oldPower = PcicReadSocket(Socket, PCIC_PWR_RST);
  87. //
  88. // Set power values
  89. //
  90. if (Enable) {
  91. //
  92. // turn power on
  93. //
  94. newPower = PC_CARDPWR_ENABLE;
  95. if (Socket->Vcc == 33) {
  96. newPower |= PC_VCC_TOPIC_033V;
  97. }
  98. //
  99. // set Vpp
  100. //
  101. if (Socket->Vcc == Socket->Vpp1) {
  102. newPower |= PC_VPP_SETTO_VCC;
  103. } else if (Socket->Vpp1 == 120) {
  104. newPower |= PC_VPP_SETTO_VPP;
  105. }
  106. } else {
  107. //
  108. // turn power off
  109. //
  110. newPower = 0;
  111. }
  112. //
  113. // Don't nuke the non-power related bits in the register..
  114. //
  115. newPower |= (oldPower & PC_PWRON_BITS);
  116. //
  117. // If Vcc is turned off, reset OUTPUT_ENABLE & AUTOPWR_ENABLE
  118. //
  119. if (!(newPower & PC_CARDPWR_ENABLE)) {
  120. newPower &= ~PC_PWRON_BITS;
  121. }
  122. //
  123. // Disable ResetDrv
  124. //
  125. newPower |= PC_RESETDRV_DISABLE;
  126. status = STATUS_SUCCESS;
  127. if (newPower != oldPower) {
  128. PcicWriteSocket(Socket, PCIC_PWR_RST, newPower);
  129. //
  130. // Allow ramp up.. (actually we don't need to this if
  131. // Enable was FALSE). Keep it for paranoia's sake
  132. //
  133. *pDelayTime = PcicStallPower;
  134. Socket->PowerData = (ULONG) newPower;
  135. status = STATUS_MORE_PROCESSING_REQUIRED;
  136. }
  137. break;
  138. case 2:
  139. newPower = (UCHAR) Socket->PowerData;
  140. if ((newPower & PC_CARDPWR_ENABLE) &&
  141. ((newPower & PC_PWRON_BITS) != PC_PWRON_BITS)) {
  142. //
  143. // More paranoia?
  144. //
  145. newPower |= PC_PWRON_BITS;
  146. PcicWriteSocket(Socket, PCIC_PWR_RST, newPower);
  147. }
  148. status = STATUS_SUCCESS;
  149. *pDelayTime = PcicStallPower;
  150. break;
  151. default:
  152. ASSERT(FALSE);
  153. status = STATUS_UNSUCCESSFUL;
  154. }
  155. return status;
  156. }
  157. VOID
  158. TopicSetAudio(
  159. IN PSOCKET Socket,
  160. IN BOOLEAN Enable
  161. )
  162. {
  163. PFDO_EXTENSION FdoExtension = Socket->DeviceExtension;
  164. ULONG data;
  165. ULONG orig_data;
  166. BOOLEAN setBit;
  167. setBit = (IsCardBusCardInSocket(Socket) ^ Enable);
  168. GetPciConfigSpace(FdoExtension, CFGSPACE_TO_CBREG_CTRL, &data, sizeof(data));
  169. orig_data = data;
  170. if (setBit) {
  171. data |= CSRCR_TO_CAUDIO_OFF;
  172. } else {
  173. data &= ~CSRCR_TO_CAUDIO_OFF;
  174. }
  175. if (orig_data != data) {
  176. SetPciConfigSpace(FdoExtension, CFGSPACE_TO_CBREG_CTRL, &data, sizeof(data));
  177. }
  178. }
  179. BOOLEAN
  180. TopicSetZV(
  181. IN PSOCKET Socket,
  182. IN BOOLEAN Enable
  183. )
  184. {
  185. UCHAR bData;
  186. if (Enable) {
  187. PcicWriteSocket(Socket, PCIC_TO_MMI_CTRL, TO_MMI_VIDEO_CTRL | TO_MMI_AUDIO_CTRL);
  188. bData = PcicReadSocket(Socket, PCIC_TO_ADDITIONAL_GENCTRL);
  189. bData |= TO_GCTRL_CARDREMOVAL_RESET;
  190. PcicWriteSocket(Socket, PCIC_TO_ADDITIONAL_GENCTRL, bData);
  191. } else {
  192. PcicWriteSocket(Socket, PCIC_TO_MMI_CTRL, 0);
  193. bData = PcicReadSocket(Socket, PCIC_TO_ADDITIONAL_GENCTRL);
  194. bData &= ~TO_GCTRL_CARDREMOVAL_RESET;
  195. PcicWriteSocket(Socket, PCIC_TO_ADDITIONAL_GENCTRL, bData);
  196. }
  197. return TRUE;
  198. }