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.

221 lines
5.7 KiB

  1. /*++
  2. Copyright (c) 1997-2000 Microsoft Corporation
  3. Module Name:
  4. ti.c
  5. Abstract:
  6. This module contains the code that contains
  7. Texas Instruments cardbus controller specific
  8. initialization 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. --*/
  16. #include "pch.h"
  17. VOID
  18. TIInitialize(
  19. IN PFDO_EXTENSION FdoExtension
  20. )
  21. /*++
  22. Routine Description:
  23. Initialize TI cardbus controllers
  24. Arguments:
  25. FdoExtension - Pointer to the device extension for the controller FDO
  26. Return Value:
  27. None
  28. --*/
  29. {
  30. UCHAR byte;
  31. USHORT word;
  32. BOOLEAN TiOldRev = FALSE;
  33. PSOCKET socket = FdoExtension->SocketList;
  34. if (FdoExtension->ControllerType == PcmciaTI1130) {
  35. UCHAR revisionID;
  36. GetPciConfigSpace(FdoExtension, CFGSPACE_REV_ID, &revisionID, 1);
  37. if (revisionID < 4) {
  38. TiOldRev = TRUE;
  39. }
  40. }
  41. GetPciConfigSpace(FdoExtension, CFGSPACE_CACHE_LINESIZE, &byte, 1);
  42. if (byte == 0) {
  43. byte = 8;
  44. SetPciConfigSpace(FdoExtension, CFGSPACE_CACHE_LINESIZE, &byte, 1);
  45. }
  46. byte = RETRY_CBRETRY_TIMEOUT_ENABLE|RETRY_PCIRETRY_TIMEOUT_ENABLE;
  47. SetPciConfigSpace(FdoExtension, CFGSPACE_TI_RETRY_STATUS, &byte, 1);
  48. GetPciConfigSpace(FdoExtension, CFGSPACE_TI_CARD_CTRL, &byte, 1);
  49. byte &= ~(CARDCTRL_CSCINT_ENABLE | CARDCTRL_FUNCINT_ENABLE |
  50. CARDCTRL_PCIINT_ENABLE);
  51. byte |= CARDCTRL_CSCINT_ENABLE | CARDCTRL_PCIINT_ENABLE;
  52. if (!TiOldRev) {
  53. byte |= CARDCTRL_FUNCINT_ENABLE;
  54. }
  55. SetPciConfigSpace(FdoExtension, CFGSPACE_TI_CARD_CTRL, &byte, 1);
  56. byte=PcicReadSocket(socket, PCIC_INTERRUPT);
  57. PcicWriteSocket(socket, PCIC_INTERRUPT , (UCHAR) (byte | IGC_INTR_ENABLE));
  58. GetPciConfigSpace(FdoExtension, CFGSPACE_TI_DEV_CTRL, &byte, 1);
  59. if ((byte & DEVCTRL_INTMODE_MASK) == DEVCTRL_INTMODE_DISABLED) {
  60. DebugPrint((PCMCIA_DEBUG_INFO, "TIInitialize: ISA interrupt mode is not enabled, assume simple ISA mode"));
  61. byte |= DEVCTRL_INTMODE_ISA;
  62. SetPciConfigSpace(FdoExtension, CFGSPACE_TI_DEV_CTRL, &byte, 1);
  63. } else if ((byte & DEVCTRL_INTMODE_MASK)==DEVCTRL_INTMODE_SERIAL) {
  64. //
  65. // We use serial interrupts
  66. //
  67. }
  68. if (((FdoExtension->ControllerType == PcmciaTI1130) || (FdoExtension->ControllerType == PcmciaTI1131)) &&
  69. ((byte & DEVCTRL_INTMODE_MASK) == DEVCTRL_INTMODE_ISA)) {
  70. FdoExtension->LegacyIrqMask = 0xCEA0; // 5, 7, 9, 10, 11, 14, 15
  71. }
  72. if ((byte & DEVCTRL_INTMODE_MASK) == DEVCTRL_INTMODE_COMPAQ) {
  73. FdoExtension->Flags |= PCMCIA_INTMODE_COMPAQ;
  74. } else {
  75. FdoExtension->Flags &= ~PCMCIA_INTMODE_COMPAQ;
  76. }
  77. //NOTE: This only initializes the page register on the 113x
  78. PcicWriteSocket(socket, PCIC_PAGE_REG, 0);
  79. //
  80. // NOTE: this is not done on win9x, I doubt we even need it. It
  81. // was previously being done because it was in the PcicRegisterInitTable.
  82. // But it was a bug to have it in that table, since this register is
  83. // adapter specific. Now I'm putting it here only for paranoia since
  84. // it has been in the driver for a long time.
  85. //
  86. // The comment in data.c was:
  87. // // Set GLOBAL_CONTROL for auto-clearing of status bit
  88. //
  89. PcicWriteSocket(socket, PCIC_TI_GLOBAL_CONTROL, 0);
  90. //
  91. // Workaround for CCLK instability problem
  92. //
  93. if ((FdoExtension->ControllerType == PcmciaTI1220) ||
  94. (FdoExtension->ControllerType == PcmciaTI1250) ||
  95. (FdoExtension->ControllerType == PcmciaTI1251B)) {
  96. CBWriteSocketRegister(socket, CBREG_TI_SKT_POWER_MANAGEMENT,
  97. (CBREG_TI_CLKCTRLLEN | CBREG_TI_CLKCTRL));
  98. }
  99. //
  100. // initialize IRQ routing to ISA
  101. //
  102. GetPciConfigSpace(FdoExtension, CFGSPACE_BRIDGE_CTRL, &word, 2);
  103. word |= BCTRL_IRQROUTING_ENABLE;
  104. SetPciConfigSpace(FdoExtension, CFGSPACE_BRIDGE_CTRL, &word, 2);
  105. }
  106. BOOLEAN
  107. TISetZV(
  108. IN PSOCKET Socket,
  109. IN BOOLEAN Enable
  110. )
  111. {
  112. UCHAR TiCardCtl;
  113. PFDO_EXTENSION FdoExtension = Socket->DeviceExtension;
  114. if (Enable) {
  115. GetPciConfigSpace(FdoExtension, CFGSPACE_TI_CARD_CTRL, &TiCardCtl, 1);
  116. TiCardCtl |= CARDCTRL_ZV_ENABLE;
  117. TiCardCtl &= ~CARDCTRL_SPKR_ENABLE;
  118. SetPciConfigSpace(FdoExtension, CFGSPACE_TI_CARD_CTRL, &TiCardCtl, 1);
  119. } else {
  120. //
  121. // check for devices that have the problem of leaking current when zv is
  122. // disabled
  123. //
  124. if ((FdoExtension->ControllerType == PcmciaTI1450) ||
  125. (FdoExtension->ControllerType == PcmciaTI1251B)) {
  126. return TRUE;
  127. }
  128. GetPciConfigSpace(FdoExtension, CFGSPACE_TI_CARD_CTRL, &TiCardCtl, 1);
  129. TiCardCtl &= ~CARDCTRL_ZV_ENABLE;
  130. TiCardCtl |= CARDCTRL_SPKR_ENABLE;
  131. SetPciConfigSpace(FdoExtension, CFGSPACE_TI_CARD_CTRL, &TiCardCtl, 1);
  132. }
  133. return TRUE;
  134. }
  135. BOOLEAN
  136. TISetWindowPage(IN PSOCKET Socket,
  137. USHORT Index,
  138. UCHAR Page)
  139. {
  140. PFDO_EXTENSION FdoExtension = Socket->DeviceExtension;
  141. ASSERT(Index <= 4);
  142. if (FdoExtension->ControllerType == PcmciaTI1031) {
  143. return FALSE;
  144. }
  145. if (FdoExtension->ControllerType != PcmciaTI1130) {
  146. return CBSetWindowPage(Socket, Index, Page);
  147. }
  148. if ((PcicReadSocket(Socket, PCIC_ADD_WIN_ENA) & WE_MEMWIN_MASK) == 0)
  149. PcicWriteSocket(Socket, PCIC_TI_MEMWIN_PAGE, Page);
  150. else if ((Page != 0) && (PcicReadSocket(Socket, PCIC_TI_MEMWIN_PAGE) != Page)) {
  151. DebugPrint((PCMCIA_DEBUG_FAIL,
  152. "PCMCIA: TISetWindowPage setting a 2nd memory window in a different 16M page (Page=%x)",
  153. Page));
  154. return FALSE;
  155. }
  156. return TRUE;
  157. }