1 /* -------------------------------------------------------------------- */
2 /* TQM8xxL Boards by TQ Components */
3 /* SC8xx Boards by SinoVee Microsystems */
4 /* -------------------------------------------------------------------- */
13 #if defined(CONFIG_CMD_PCMCIA)
17 #if defined(CONFIG_CMD_IDE) && defined(CONFIG_IDE_8xx_PCCARD)
21 #if defined(CONFIG_PCMCIA) \
22 && (defined(CONFIG_TQM8xxL) || defined(CONFIG_SVM_SC8xx))
24 #if defined(CONFIG_VIRTLAB2)
25 #define PCMCIA_BOARD_MSG "Virtlab2"
26 #elif defined(CONFIG_TQM8xxL)
27 #define PCMCIA_BOARD_MSG "TQM8xxL"
28 #elif defined(CONFIG_SVM_SC8xx)
29 #define PCMCIA_BOARD_MSG "SC8xx"
32 #if defined(CONFIG_NSCU)
34 #define power_config(slot) do {} while (0)
35 #define power_off(slot) do {} while (0)
36 #define power_on_5_0(slot) do {} while (0)
37 #define power_on_3_3(slot) do {} while (0)
39 #elif defined(CONFIG_VIRTLAB2)
41 #define power_config(slot) do {} while (0)
42 static inline void power_off(int slot)
44 volatile unsigned char *powerctl =
45 (volatile unsigned char *)PCMCIA_CTRL;
49 static inline void power_on_5_0(int slot)
51 volatile unsigned char *powerctl =
52 (volatile unsigned char *)PCMCIA_CTRL;
53 *powerctl = 2; /* Enable 5V Vccout */
56 static inline void power_on_3_3(int slot)
58 volatile unsigned char *powerctl =
59 (volatile unsigned char *)PCMCIA_CTRL;
60 *powerctl = 1; /* Enable 3.3V Vccout */
65 static inline void power_config(int slot)
67 volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
69 * Configure Port C pins for
70 * 5 Volts Enable and 3 Volts enable
72 immap->im_ioport.iop_pcpar &= ~(0x0002 | 0x0004);
73 immap->im_ioport.iop_pcso &= ~(0x0002 | 0x0004);
76 static inline void power_off(int slot)
78 volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
79 immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
82 static inline void power_on_5_0(int slot)
84 volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
85 immap->im_ioport.iop_pcdat |= 0x0004;
86 immap->im_ioport.iop_pcdir |= (0x0002 | 0x0004);
89 static inline void power_on_3_3(int slot)
91 volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
92 immap->im_ioport.iop_pcdat |= 0x0002;
93 immap->im_ioport.iop_pcdir |= (0x0002 | 0x0004);
98 static inline int check_card_is_absent(int slot)
100 volatile pcmconf8xx_t *pcmp =
101 (pcmconf8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_pcmcia));
102 return pcmp->pcmc_pipr & (0x18000000 >> (slot << 4));
106 #define NSCU_GCRX_CXOE 0
108 #define NSCU_GCRX_CXOE __MY_PCMCIA_GCRX_CXOE
111 int pcmcia_hardware_enable(int slot)
113 volatile pcmconf8xx_t *pcmp =
114 (pcmconf8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_pcmcia));
115 volatile sysconf8xx_t *sysp =
116 (sysconf8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_siu_conf));
119 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
124 * Configure SIUMCR to enable PCMCIA port B
125 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
127 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
129 /* clear interrupt state, and disable interrupts */
130 pcmp->pcmc_pscr = PCMCIA_MASK(slot);
131 pcmp->pcmc_per &= ~PCMCIA_MASK(slot);
134 * Disable interrupts, DMA, and PCMCIA buffers
135 * (isolate the interface) and assert RESET signal
137 debug ("Disable PCMCIA buffers and assert RESET\n");
139 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
140 reg |= NSCU_GCRX_CXOE;
142 PCMCIA_PGCRX(slot) = reg;
149 * Make sure there is a card in the slot, then configure the interface.
152 debug ("[%d] %s: PIPR(%p)=0x%x\n", __LINE__,__FUNCTION__,
153 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
155 if (check_card_is_absent(slot)) {
156 printf (" No Card found\n");
163 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
164 reg = pcmp->pcmc_pipr;
165 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
167 (reg&PCMCIA_VS1(slot))?"n":"ff",
168 (reg&PCMCIA_VS2(slot))?"n":"ff");
170 if ((reg & mask) == mask) {
172 puts (" 5.0V card found: ");
175 puts (" 3.3V card found: ");
179 /* VCC switch error flag, PCMCIA slot INPACK_ pin */
180 cp->cp_pbdir &= ~(0x0020 | 0x0010);
181 cp->cp_pbpar &= ~(0x0020 | 0x0010);
186 debug ("Enable PCMCIA buffers and stop RESET\n");
187 reg = PCMCIA_PGCRX(slot);
188 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
189 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
190 reg &= ~NSCU_GCRX_CXOE;
192 PCMCIA_PGCRX(slot) = reg;
194 udelay(250000); /* some cards need >150 ms to come up :-( */
196 debug ("# hardware_enable done\n");
202 #if defined(CONFIG_CMD_PCMCIA)
203 int pcmcia_hardware_disable(int slot)
207 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
210 /* remove all power */
213 debug ("Disable PCMCIA buffers and assert RESET\n");
215 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
216 reg |= NSCU_GCRX_CXOE; /* active low */
218 PCMCIA_PGCRX(slot) = reg;
226 int pcmcia_voltage_set(int slot, int vcc, int vpp)
231 volatile pcmconf8xx_t *pcmp =
232 (pcmconf8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_pcmcia));
235 debug ("voltage_set: " PCMCIA_BOARD_MSG
236 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
237 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
240 * Disable PCMCIA buffers (isolate the interface)
241 * and assert RESET signal
243 debug ("Disable PCMCIA buffers and assert RESET\n");
244 reg = PCMCIA_PGCRX(slot);
245 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
246 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
247 reg |= NSCU_GCRX_CXOE; /* active low */
249 PCMCIA_PGCRX(slot) = reg;
252 debug ("PCMCIA power OFF\n");
258 case 33: power_on_3_3(slot); break;
259 case 50: power_on_5_0(slot); break;
263 /* Checking supported voltages */
265 debug("PIPR: 0x%x --> %s\n", pcmp->pcmc_pipr,
266 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
269 debug("PCMCIA powered at %sV\n", (vcc == 50) ? "5.0" : "3.3");
271 debug("PCMCIA powered down\n");
274 debug("Enable PCMCIA buffers and stop RESET\n");
275 reg = PCMCIA_PGCRX(slot);
276 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
277 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
278 reg &= ~NSCU_GCRX_CXOE; /* active low */
280 PCMCIA_PGCRX(slot) = reg;
283 debug("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n", slot+'A');
284 #endif /* CONFIG_NSCU */
288 #endif /* CONFIG_PCMCIA && (CONFIG_TQM8xxL || CONFIG_SVM_SC8xx) */