1 /* -------------------------------------------------------------------- */
2 /* TQM8xxL Boards by TQ Components */
3 /* SC8xx Boards by SinoVee Microsystems */
4 /* -------------------------------------------------------------------- */
13 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
17 #if (CONFIG_COMMANDS & CFG_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_HMI10)
41 static inline void power_config(int slot)
43 volatile immap_t *immap = (immap_t *)CFG_IMMR;
45 * Configure Port B pins for
46 * 5 Volts Enable and 3 Volts enable
48 immap->im_cpm.cp_pbpar &= ~(0x00000300);
51 static inline void power_off(int slot)
53 volatile immap_t *immap = (immap_t *)CFG_IMMR;
54 /* remove all power */
55 immap->im_cpm.cp_pbdat |= 0x00000300;
58 static inline void power_on_5_0(int slot)
60 volatile immap_t *immap = (immap_t *)CFG_IMMR;
61 immap->im_cpm.cp_pbdat &= ~(0x0000100);
62 immap->im_cpm.cp_pbdir |= 0x00000300;
65 static inline void power_on_3_3(int slot)
67 volatile immap_t *immap = (immap_t *)CFG_IMMR;
68 immap->im_cpm.cp_pbdat &= ~(0x0000200);
69 immap->im_cpm.cp_pbdir |= 0x00000300;
72 #elif defined(CONFIG_VIRTLAB2)
74 #define power_config(slot) do {} while (0)
75 static inline void power_off(int slot)
77 volatile unsigned char *powerctl =
78 (volatile unsigned char *)PCMCIA_CTRL;
82 static inline void power_on_5_0(int slot)
84 volatile unsigned char *powerctl =
85 (volatile unsigned char *)PCMCIA_CTRL;
86 *powerctl = 2; /* Enable 5V Vccout */
89 static inline void power_on_3_3(int slot)
91 volatile unsigned char *powerctl =
92 (volatile unsigned char *)PCMCIA_CTRL;
93 *powerctl = 1; /* Enable 3.3V Vccout */
98 static inline void power_config(int slot)
100 volatile immap_t *immap = (immap_t *)CFG_IMMR;
102 * Configure Port C pins for
103 * 5 Volts Enable and 3 Volts enable
105 immap->im_ioport.iop_pcpar &= ~(0x0002 | 0x0004);
106 immap->im_ioport.iop_pcso &= ~(0x0002 | 0x0004);
109 static inline void power_off(int slot)
111 volatile immap_t *immap = (immap_t *)CFG_IMMR;
112 immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
115 static inline void power_on_5_0(int slot)
117 volatile immap_t *immap = (immap_t *)CFG_IMMR;
118 immap->im_ioport.iop_pcdat |= 0x0004;
119 immap->im_ioport.iop_pcdir |= (0x0002 | 0x0004);
122 static inline void power_on_3_3(int slot)
124 volatile immap_t *immap = (immap_t *)CFG_IMMR;
125 immap->im_ioport.iop_pcdat |= 0x0002;
126 immap->im_ioport.iop_pcdir |= (0x0002 | 0x0004);
132 static inline int check_card_is_absent(int slot)
134 volatile pcmconf8xx_t *pcmp =
135 (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
136 return pcmp->pcmc_pipr & (0x10000000 >> (slot << 4));
139 static inline int check_card_is_absent(int slot)
141 volatile pcmconf8xx_t *pcmp =
142 (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
143 return pcmp->pcmc_pipr & (0x18000000 >> (slot << 4));
148 #define NSCU_GCRX_CXOE 0
150 #define NSCU_GCRX_CXOE __MY_PCMCIA_GCRX_CXOE
153 int pcmcia_hardware_enable(int slot)
155 volatile pcmconf8xx_t *pcmp =
156 (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
157 volatile sysconf8xx_t *sysp =
158 (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
161 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
166 * Configure SIUMCR to enable PCMCIA port B
167 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
169 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
171 /* clear interrupt state, and disable interrupts */
172 pcmp->pcmc_pscr = PCMCIA_MASK(slot);
173 pcmp->pcmc_per &= ~PCMCIA_MASK(slot);
176 * Disable interrupts, DMA, and PCMCIA buffers
177 * (isolate the interface) and assert RESET signal
179 debug ("Disable PCMCIA buffers and assert RESET\n");
181 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
182 reg |= NSCU_GCRX_CXOE;
184 PCMCIA_PGCRX(slot) = reg;
191 * Make sure there is a card in the slot, then configure the interface.
194 debug ("[%d] %s: PIPR(%p)=0x%x\n", __LINE__,__FUNCTION__,
195 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
197 if (check_card_is_absent(slot)) {
198 printf (" No Card found\n");
205 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
206 reg = pcmp->pcmc_pipr;
207 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
209 (reg&PCMCIA_VS1(slot))?"n":"ff",
210 (reg&PCMCIA_VS2(slot))?"n":"ff");
212 if ((reg & mask) == mask) {
214 puts (" 5.0V card found: ");
217 puts (" 3.3V card found: ");
221 /* VCC switch error flag, PCMCIA slot INPACK_ pin */
222 cp->cp_pbdir &= ~(0x0020 | 0x0010);
223 cp->cp_pbpar &= ~(0x0020 | 0x0010);
228 debug ("Enable PCMCIA buffers and stop RESET\n");
229 reg = PCMCIA_PGCRX(slot);
230 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
231 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
232 reg &= ~NSCU_GCRX_CXOE;
234 PCMCIA_PGCRX(slot) = reg;
236 udelay(250000); /* some cards need >150 ms to come up :-( */
238 debug ("# hardware_enable done\n");
244 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
245 int pcmcia_hardware_disable(int slot)
249 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
252 /* remove all power */
255 debug ("Disable PCMCIA buffers and assert RESET\n");
257 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
258 reg |= NSCU_GCRX_CXOE; /* active low */
260 PCMCIA_PGCRX(slot) = reg;
266 #endif /* CFG_CMD_PCMCIA */
268 int pcmcia_voltage_set(int slot, int vcc, int vpp)
273 volatile pcmconf8xx_t *pcmp =
274 (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
277 debug ("voltage_set: " PCMCIA_BOARD_MSG
278 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
279 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
282 * Disable PCMCIA buffers (isolate the interface)
283 * and assert RESET signal
285 debug ("Disable PCMCIA buffers and assert RESET\n");
286 reg = PCMCIA_PGCRX(slot);
287 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
288 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
289 reg |= NSCU_GCRX_CXOE; /* active low */
291 PCMCIA_PGCRX(slot) = reg;
294 debug ("PCMCIA power OFF\n");
300 case 33: power_on_3_3(slot); break;
301 case 50: power_on_5_0(slot); break;
305 /* Checking supported voltages */
307 debug("PIPR: 0x%x --> %s\n", pcmp->pcmc_pipr,
308 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
311 debug("PCMCIA powered at %sV\n", (vcc == 50) ? "5.0" : "3.3");
313 debug("PCMCIA powered down\n");
316 debug("Enable PCMCIA buffers and stop RESET\n");
317 reg = PCMCIA_PGCRX(slot);
318 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
319 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
320 reg &= ~NSCU_GCRX_CXOE; /* active low */
322 PCMCIA_PGCRX(slot) = reg;
325 debug("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n", slot+'A');
326 #endif /* CONFIG_NSCU */
330 #endif /* CONFIG_PCMCIA && (CONFIG_TQM8xxL || CONFIG_SVM_SC8xx) */