pcmcia.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. #include <common.h>
  2. #include <mpc8xx.h>
  3. #include <pcmcia.h>
  4. #undef CONFIG_PCMCIA
  5. #if defined(CONFIG_CMD_PCMCIA)
  6. #define CONFIG_PCMCIA
  7. #endif
  8. #if (defined(CONFIG_CMD_IDE)) && defined(CONFIG_IDE_8xx_PCCARD)
  9. #define CONFIG_PCMCIA
  10. #endif
  11. #ifdef CONFIG_PCMCIA
  12. #define PCMCIA_BOARD_MSG "UC100"
  13. /*
  14. * Remark: don't turn off OE "__MY_PCMCIA_GCRX_CXOE" on UC100 board.
  15. * This leads to board-hangup! (sr, 8 Dez. 2004)
  16. */
  17. static void cfg_ports (void)
  18. {
  19. volatile immap_t *immap;
  20. immap = (immap_t *)CONFIG_SYS_IMMR;
  21. /*
  22. * Configure Port A for MAX1602 PC-Card Power-Interface Switch
  23. */
  24. immap->im_ioport.iop_padat &= ~0x8000; /* set port x output to low */
  25. immap->im_ioport.iop_padir |= 0x8000; /* enable port x as output */
  26. debug ("Set Port A: PAR: %08x DIR: %08x DAT: %08x\n",
  27. immap->im_ioport.iop_papar, immap->im_ioport.iop_padir,
  28. immap->im_ioport.iop_padat);
  29. }
  30. int pcmcia_hardware_enable(int slot)
  31. {
  32. volatile immap_t *immap;
  33. volatile cpm8xx_t *cp;
  34. volatile pcmconf8xx_t *pcmp;
  35. volatile sysconf8xx_t *sysp;
  36. uint reg, mask;
  37. debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  38. udelay(10000);
  39. immap = (immap_t *)CONFIG_SYS_IMMR;
  40. sysp = (sysconf8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_siu_conf));
  41. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_pcmcia));
  42. cp = (cpm8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_cpm));
  43. /* Configure Ports for TPS2211A PC-Card Power-Interface Switch */
  44. cfg_ports ();
  45. /*
  46. * Configure SIUMCR to enable PCMCIA port B
  47. * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
  48. */
  49. sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
  50. /* clear interrupt state, and disable interrupts */
  51. pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
  52. pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
  53. /*
  54. * Disable interrupts, DMA, and PCMCIA buffers
  55. * (isolate the interface) and assert RESET signal
  56. */
  57. debug ("Disable PCMCIA buffers and assert RESET\n");
  58. reg = 0;
  59. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  60. PCMCIA_PGCRX(_slot_) = reg;
  61. udelay(500);
  62. /*
  63. * Make sure there is a card in the slot, then configure the interface.
  64. */
  65. udelay(10000);
  66. debug ("[%d] %s: PIPR(%p)=0x%x\n",
  67. __LINE__,__FUNCTION__,
  68. &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
  69. if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
  70. printf (" No Card found\n");
  71. return (1);
  72. }
  73. /*
  74. * Power On.
  75. */
  76. mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
  77. reg = pcmp->pcmc_pipr;
  78. debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
  79. reg,
  80. (reg&PCMCIA_VS1(slot))?"n":"ff",
  81. (reg&PCMCIA_VS2(slot))?"n":"ff");
  82. if ((reg & mask) == mask) {
  83. puts (" 5.0V card found: ");
  84. } else {
  85. puts (" 3.3V card found: ");
  86. }
  87. /* switch VCC on */
  88. immap->im_ioport.iop_padat |= 0x8000; /* power enable 3.3V */
  89. udelay(10000);
  90. debug ("Enable PCMCIA buffers and stop RESET\n");
  91. reg = PCMCIA_PGCRX(_slot_);
  92. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  93. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  94. PCMCIA_PGCRX(_slot_) = reg;
  95. udelay(250000); /* some cards need >150 ms to come up :-( */
  96. debug ("# hardware_enable done\n");
  97. return (0);
  98. }
  99. #if defined(CONFIG_CMD_PCMCIA)
  100. int pcmcia_hardware_disable(int slot)
  101. {
  102. volatile immap_t *immap;
  103. volatile cpm8xx_t *cp;
  104. volatile pcmconf8xx_t *pcmp;
  105. u_long reg;
  106. debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
  107. immap = (immap_t *)CONFIG_SYS_IMMR;
  108. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_pcmcia));
  109. /* switch VCC off */
  110. immap->im_ioport.iop_padat &= ~0x8000; /* power disable 3.3V */
  111. /* Configure PCMCIA General Control Register */
  112. debug ("Disable PCMCIA buffers and assert RESET\n");
  113. reg = 0;
  114. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  115. PCMCIA_PGCRX(_slot_) = reg;
  116. udelay(10000);
  117. return (0);
  118. }
  119. #endif
  120. int pcmcia_voltage_set(int slot, int vcc, int vpp)
  121. {
  122. volatile immap_t *immap;
  123. volatile pcmconf8xx_t *pcmp;
  124. u_long reg;
  125. debug ("voltage_set: "
  126. PCMCIA_BOARD_MSG
  127. " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
  128. 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
  129. immap = (immap_t *)CONFIG_SYS_IMMR;
  130. pcmp = (pcmconf8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_pcmcia));
  131. /*
  132. * Disable PCMCIA buffers (isolate the interface)
  133. * and assert RESET signal
  134. */
  135. debug ("Disable PCMCIA buffers and assert RESET\n");
  136. reg = PCMCIA_PGCRX(_slot_);
  137. reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
  138. PCMCIA_PGCRX(_slot_) = reg;
  139. udelay(500);
  140. /*
  141. * Configure Port C pins for
  142. * 5 Volts Enable and 3 Volts enable,
  143. * Turn all power pins to Hi-Z
  144. */
  145. debug ("PCMCIA power OFF\n");
  146. cfg_ports (); /* Enables switch, but all in Hi-Z */
  147. debug ("Enable PCMCIA buffers and stop RESET\n");
  148. reg = PCMCIA_PGCRX(_slot_);
  149. reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
  150. reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
  151. PCMCIA_PGCRX(_slot_) = reg;
  152. udelay(500);
  153. debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
  154. slot+'A');
  155. return (0);
  156. }
  157. #endif /* CONFIG_PCMCIA */