pcmcia.c 4.6 KB

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