]>
git.ipfire.org Git - people/ms/u-boot.git/blob - drivers/tqm8xx_pcmcia.c
1 /* -------------------------------------------------------------------- */
2 /* TQM8xxL Boards by TQ Components */
3 /* SC8xx Boards by SinoVee Microsystems */
4 /* -------------------------------------------------------------------- */
11 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
15 #if (CONFIG_COMMANDS & CFG_CMD_IDE) && defined(CONFIG_IDE_8xx_PCCARD)
19 #if defined(CONFIG_PCMCIA) \
20 && (defined(CONFIG_TQM8xxL) || defined(CONFIG_SVM_SC8xx))
22 #if defined(CONFIG_VIRTLAB2)
23 #define PCMCIA_BOARD_MSG "Virtlab2"
24 #elif defined(CONFIG_TQM8xxL)
25 #define PCMCIA_BOARD_MSG "TQM8xxL"
26 #elif defined(CONFIG_SVM_SC8xx)
27 #define PCMCIA_BOARD_MSG "SC8xx"
30 #if defined(CONFIG_NSCU)
32 #define power_config(slot) do {} while (0)
33 #define power_off(slot) do {} while (0)
34 #define power_on_5_0(slot) do {} while (0)
35 #define power_on_3_3(slot) do {} while (0)
37 #elif defined(CONFIG_HMI10)
39 static inline void power_config(int slot
)
41 volatile immap_t
*immap
= (immap_t
*)CFG_IMMR
;
43 * Configure Port B pins for
44 * 5 Volts Enable and 3 Volts enable
46 immap
->im_cpm
.cp_pbpar
&= ~(0x00000300);
49 static inline void power_off(int slot
)
51 volatile immap_t
*immap
= (immap_t
*)CFG_IMMR
;
52 /* remove all power */
53 immap
->im_cpm
.cp_pbdat
|= 0x00000300;
56 static inline void power_on_5_0(int slot
)
58 volatile immap_t
*immap
= (immap_t
*)CFG_IMMR
;
59 immap
->im_cpm
.cp_pbdat
&= ~(0x0000100);
60 immap
->im_cpm
.cp_pbdir
|= 0x00000300;
63 static inline void power_on_3_3(int slot
)
65 volatile immap_t
*immap
= (immap_t
*)CFG_IMMR
;
66 immap
->im_cpm
.cp_pbdat
&= ~(0x0000200);
67 immap
->im_cpm
.cp_pbdir
|= 0x00000300;
70 #elif defined(CONFIG_VIRTLAB2)
72 #define power_config(slot) do {} while (0)
73 static inline void power_off(int slot
)
75 volatile unsigned char *powerctl
=
76 (volatile unsigned char *)PCMCIA_CTRL
;
80 static inline void power_on_5_0(int slot
)
82 volatile unsigned char *powerctl
=
83 (volatile unsigned char *)PCMCIA_CTRL
;
84 *powerctl
= 2; /* Enable 5V Vccout */
87 static inline void power_on_3_3(int slot
)
89 volatile unsigned char *powerctl
=
90 (volatile unsigned char *)PCMCIA_CTRL
;
91 *powerctl
= 1; /* Enable 3.3V Vccout */
96 static inline void power_config(int slot
)
98 volatile immap_t
*immap
= (immap_t
*)CFG_IMMR
;
100 * Configure Port C pins for
101 * 5 Volts Enable and 3 Volts enable
103 immap
->im_ioport
.iop_pcpar
&= ~(0x0002 | 0x0004);
104 immap
->im_ioport
.iop_pcso
&= ~(0x0002 | 0x0004);
107 static inline void power_off(int slot
)
109 volatile immap_t
*immap
= (immap_t
*)CFG_IMMR
;
110 immap
->im_ioport
.iop_pcdat
&= ~(0x0002 | 0x0004);
113 static inline void power_on_5_0(int slot
)
115 volatile immap_t
*immap
= (immap_t
*)CFG_IMMR
;
116 immap
->im_ioport
.iop_pcdat
|= 0x0004;
117 immap
->im_ioport
.iop_pcdir
|= (0x0002 | 0x0004);
120 static inline void power_on_3_3(int slot
)
122 volatile immap_t
*immap
= (immap_t
*)CFG_IMMR
;
123 immap
->im_ioport
.iop_pcdat
|= 0x0002;
124 immap
->im_ioport
.iop_pcdir
|= (0x0002 | 0x0004);
130 static inline int check_card_is_absent(int slot
)
132 volatile pcmconf8xx_t
*pcmp
=
133 (pcmconf8xx_t
*)(&(((immap_t
*)CFG_IMMR
)->im_pcmcia
));
134 return pcmp
->pcmc_pipr
& (0x10000000 >> (slot
<< 4));
137 static inline int check_card_is_absent(int slot
)
139 volatile pcmconf8xx_t
*pcmp
=
140 (pcmconf8xx_t
*)(&(((immap_t
*)CFG_IMMR
)->im_pcmcia
));
141 return pcmp
->pcmc_pipr
& (0x18000000 >> (slot
<< 4));
146 #define NSCU_GCRX_CXOE 0
148 #define NSCU_GCRX_CXOE __MY_PCMCIA_GCRX_CXOE
151 int pcmcia_hardware_enable(int slot
)
153 volatile pcmconf8xx_t
*pcmp
=
154 (pcmconf8xx_t
*)(&(((immap_t
*)CFG_IMMR
)->im_pcmcia
));
155 volatile sysconf8xx_t
*sysp
=
156 (sysconf8xx_t
*)(&(((immap_t
*)CFG_IMMR
)->im_siu_conf
));
159 debug ("hardware_enable: " PCMCIA_BOARD_MSG
" Slot %c\n", 'A'+slot
);
164 * Configure SIUMCR to enable PCMCIA port B
165 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
167 sysp
->sc_siumcr
&= ~SIUMCR_DBGC11
; /* set DBGC to 00 */
169 /* clear interrupt state, and disable interrupts */
170 pcmp
->pcmc_pscr
= PCMCIA_MASK(slot
);
171 pcmp
->pcmc_per
&= ~PCMCIA_MASK(slot
);
174 * Disable interrupts, DMA, and PCMCIA buffers
175 * (isolate the interface) and assert RESET signal
177 debug ("Disable PCMCIA buffers and assert RESET\n");
179 reg
|= __MY_PCMCIA_GCRX_CXRESET
; /* active high */
180 reg
|= NSCU_GCRX_CXOE
;
182 PCMCIA_PGCRX(slot
) = reg
;
189 * Make sure there is a card in the slot, then configure the interface.
192 debug ("[%d] %s: PIPR(%p)=0x%x\n", __LINE__
,__FUNCTION__
,
193 &(pcmp
->pcmc_pipr
),pcmp
->pcmc_pipr
);
195 if (check_card_is_absent(slot
)) {
196 printf (" No Card found\n");
203 mask
= PCMCIA_VS1(slot
) | PCMCIA_VS2(slot
);
204 reg
= pcmp
->pcmc_pipr
;
205 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
207 (reg
&PCMCIA_VS1(slot
))?"n":"ff",
208 (reg
&PCMCIA_VS2(slot
))?"n":"ff");
210 if ((reg
& mask
) == mask
) {
212 puts (" 5.0V card found: ");
215 puts (" 3.3V card found: ");
219 /* VCC switch error flag, PCMCIA slot INPACK_ pin */
220 cp
->cp_pbdir
&= ~(0x0020 | 0x0010);
221 cp
->cp_pbpar
&= ~(0x0020 | 0x0010);
226 debug ("Enable PCMCIA buffers and stop RESET\n");
227 reg
= PCMCIA_PGCRX(slot
);
228 reg
&= ~__MY_PCMCIA_GCRX_CXRESET
; /* active high */
229 reg
|= __MY_PCMCIA_GCRX_CXOE
; /* active low */
230 reg
&= ~NSCU_GCRX_CXOE
;
232 PCMCIA_PGCRX(slot
) = reg
;
234 udelay(250000); /* some cards need >150 ms to come up :-( */
236 debug ("# hardware_enable done\n");
242 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA)
243 int pcmcia_hardware_disable(int slot
)
245 volatile pcmconf8xx_t
*pcmp
=
246 (pcmconf8xx_t
*)(&(((immap_t
*)CFG_IMMR
)->im_pcmcia
));
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
)
271 volatile pcmconf8xx_t
*pcmp
=
272 (pcmconf8xx_t
*)(&(((immap_t
*)CFG_IMMR
)->im_pcmcia
));
275 debug ("voltage_set: " PCMCIA_BOARD_MSG
276 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
277 'A'+slot
, vcc
/10, vcc
%10, vpp
/10, vcc
%10);
280 * Disable PCMCIA buffers (isolate the interface)
281 * and assert RESET signal
283 debug ("Disable PCMCIA buffers and assert RESET\n");
284 reg
= PCMCIA_PGCRX(slot
);
285 reg
|= __MY_PCMCIA_GCRX_CXRESET
; /* active high */
286 reg
&= ~__MY_PCMCIA_GCRX_CXOE
; /* active low */
287 reg
|= NSCU_GCRX_CXOE
; /* active low */
289 PCMCIA_PGCRX(slot
) = reg
;
292 debug ("PCMCIA power OFF\n");
298 case 33: power_on_3_3(slot
); break;
299 case 50: power_on_5_0(slot
); break;
303 /* Checking supported voltages */
305 debug("PIPR: 0x%x --> %s\n", pcmp
->pcmc_pipr
,
306 (pcmp
->pcmc_pipr
& 0x00008000) ? "only 5 V" : "can do 3.3V");
309 debug("PCMCIA powered at %sV\n", (vcc
== 50) ? "5.0" : "3.3");
311 debug("PCMCIA powered down\n");
314 debug("Enable PCMCIA buffers and stop RESET\n");
315 reg
= PCMCIA_PGCRX(slot
);
316 reg
&= ~__MY_PCMCIA_GCRX_CXRESET
; /* active high */
317 reg
|= __MY_PCMCIA_GCRX_CXOE
; /* active low */
318 reg
&= ~NSCU_GCRX_CXOE
; /* active low */
320 PCMCIA_PGCRX(slot
) = reg
;
323 debug("voltage_set: " PCMCIA_BOARD_MSG
" Slot %c, DONE\n", slot
+'A');
324 #endif /* CONFIG_NSCU */
328 #endif /* CONFIG_PCMCIA && (CONFIG_TQM8xxL || CONFIG_SVM_SC8xx) */