]>
git.ipfire.org Git - people/ms/u-boot.git/blob - board/icu862/pcmcia.c
7 #if defined(CONFIG_CMD_PCMCIA)
11 #if defined(CONFIG_CMD_IDE) && defined(CONFIG_IDE_8xx_PCCARD)
17 #define PCMCIA_BOARD_MSG "ICU862"
19 static void cfg_port_B (void)
21 volatile immap_t
*immap
;
22 volatile cpm8xx_t
*cp
;
25 immap
= (immap_t
*)CONFIG_SYS_IMMR
;
26 cp
= (cpm8xx_t
*)(&(((immap_t
*)CONFIG_SYS_IMMR
)->im_cpm
));
29 * Configure Port B for TPS2205 PC-Card Power-Interface Switch
31 * Switch off all voltages, assert shutdown
34 reg
|= (TPS2205_VPP_PGM
| TPS2205_VPP_VCC
| /* VAVPP => Hi-Z */
35 TPS2205_VCC3
| TPS2205_VCC5
| /* VAVCC => Hi-Z */
36 TPS2205_SHDN
); /* enable switch */
39 cp
->cp_pbpar
&= ~(TPS2205_INPUTS
| TPS2205_OUTPUTS
);
41 reg
= cp
->cp_pbdir
& ~(TPS2205_INPUTS
);
42 cp
->cp_pbdir
= reg
| TPS2205_OUTPUTS
;
44 debug ("Set Port B: PAR: %08x DIR: %08x DAT: %08x\n",
45 cp
->cp_pbpar
, cp
->cp_pbdir
, cp
->cp_pbdat
);
48 int pcmcia_hardware_enable(int slot
)
50 volatile immap_t
*immap
;
51 volatile cpm8xx_t
*cp
;
52 volatile pcmconf8xx_t
*pcmp
;
53 volatile sysconf8xx_t
*sysp
;
57 debug ("hardware_enable: " PCMCIA_BOARD_MSG
" Slot %c\n", 'A'+slot
);
61 immap
= (immap_t
*)CONFIG_SYS_IMMR
;
62 sysp
= (sysconf8xx_t
*)(&(((immap_t
*)CONFIG_SYS_IMMR
)->im_siu_conf
));
63 pcmp
= (pcmconf8xx_t
*)(&(((immap_t
*)CONFIG_SYS_IMMR
)->im_pcmcia
));
64 cp
= (cpm8xx_t
*)(&(((immap_t
*)CONFIG_SYS_IMMR
)->im_cpm
));
66 /* Configure Port B for TPS2205 PC-Card Power-Interface Switch */
70 * Configure SIUMCR to enable PCMCIA port B
71 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
73 sysp
->sc_siumcr
&= ~SIUMCR_DBGC11
; /* set DBGC to 00 */
75 /* clear interrupt state, and disable interrupts */
76 pcmp
->pcmc_pscr
= PCMCIA_MASK(_slot_
);
77 pcmp
->pcmc_per
&= ~PCMCIA_MASK(_slot_
);
80 * Disable interrupts, DMA, and PCMCIA buffers
81 * (isolate the interface) and assert RESET signal
83 debug ("Disable PCMCIA buffers and assert RESET\n");
85 reg
|= __MY_PCMCIA_GCRX_CXRESET
; /* active high */
86 reg
|= __MY_PCMCIA_GCRX_CXOE
; /* active low */
87 PCMCIA_PGCRX(_slot_
) = reg
;
91 * Make sure there is a card in the slot, then configure the interface.
94 debug ("[%d] %s: PIPR(%p)=0x%x\n",
95 __LINE__
,__FUNCTION__
,
96 &(pcmp
->pcmc_pipr
),pcmp
->pcmc_pipr
);
97 if (pcmp
->pcmc_pipr
& (0x18000000 >> (slot
<< 4))) {
98 printf (" No Card found\n");
103 * Power On: Set VAVCC to 3.3V or 5V, set VAVPP to Hi-Z
105 mask
= PCMCIA_VS1(slot
) | PCMCIA_VS2(slot
);
106 pipr
= pcmp
->pcmc_pipr
;
107 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
109 (reg
&PCMCIA_VS1(slot
))?"n":"ff",
110 (reg
&PCMCIA_VS2(slot
))?"n":"ff");
113 if ((pipr
& mask
) == mask
) {
114 reg
|= (TPS2205_VPP_PGM
| TPS2205_VPP_VCC
| /* VAVPP => Hi-Z */
115 TPS2205_VCC3
); /* 3V off */
116 reg
&= ~(TPS2205_VCC5
); /* 5V on */
117 puts (" 5.0V card found: ");
119 reg
|= (TPS2205_VPP_PGM
| TPS2205_VPP_VCC
| /* VAVPP => Hi-Z */
120 TPS2205_VCC5
); /* 5V off */
121 reg
&= ~(TPS2205_VCC3
); /* 3V on */
122 puts (" 3.3V card found: ");
125 debug ("\nPB DAT: %08x -> 3.3V %s 5.0V %s VPP_PGM %s VPP_VCC %s\n",
127 (reg
& TPS2205_VCC3
) ? "off" : "on",
128 (reg
& TPS2205_VCC5
) ? "off" : "on",
129 (reg
& TPS2205_VPP_PGM
) ? "off" : "on",
130 (reg
& TPS2205_VPP_VCC
) ? "off" : "on" );
134 /* Wait 500 ms; use this to check for over-current */
135 for (i
=0; i
<5000; ++i
) {
136 if ((cp
->cp_pbdat
& TPS2205_OC
) == 0) {
137 printf (" *** Overcurrent - Safety shutdown ***\n");
138 cp
->cp_pbdat
&= ~(TPS2205_SHDN
);
144 debug ("Enable PCMCIA buffers and stop RESET\n");
145 reg
= PCMCIA_PGCRX(_slot_
);
146 reg
&= ~__MY_PCMCIA_GCRX_CXRESET
; /* active high */
147 reg
&= ~__MY_PCMCIA_GCRX_CXOE
; /* active low */
148 PCMCIA_PGCRX(_slot_
) = reg
;
150 udelay(250000); /* some cards need >150 ms to come up :-( */
152 debug ("# hardware_enable done\n");
158 #if defined(CONFIG_CMD_PCMCIA)
159 int pcmcia_hardware_disable(int slot
)
161 volatile immap_t
*immap
;
162 volatile cpm8xx_t
*cp
;
163 volatile pcmconf8xx_t
*pcmp
;
166 debug ("hardware_disable: " PCMCIA_BOARD_MSG
" Slot %c\n", 'A'+slot
);
168 immap
= (immap_t
*)CONFIG_SYS_IMMR
;
169 cp
= (cpm8xx_t
*)(&(((immap_t
*)CONFIG_SYS_IMMR
)->im_cpm
));
170 pcmp
= (pcmconf8xx_t
*)(&(((immap_t
*)CONFIG_SYS_IMMR
)->im_pcmcia
));
173 cp
->cp_pbdat
&= ~(TPS2205_SHDN
);
175 /* Configure PCMCIA General Control Register */
176 debug ("Disable PCMCIA buffers and assert RESET\n");
178 reg
|= __MY_PCMCIA_GCRX_CXRESET
; /* active high */
179 reg
|= __MY_PCMCIA_GCRX_CXOE
; /* active low */
180 PCMCIA_PGCRX(_slot_
) = reg
;
189 int pcmcia_voltage_set(int slot
, int vcc
, int vpp
)
191 volatile immap_t
*immap
;
192 volatile cpm8xx_t
*cp
;
193 volatile pcmconf8xx_t
*pcmp
;
196 debug ("voltage_set: "
198 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
199 'A'+slot
, vcc
/10, vcc
%10, vpp
/10, vcc
%10);
201 immap
= (immap_t
*)CONFIG_SYS_IMMR
;
202 cp
= (cpm8xx_t
*)(&(((immap_t
*)CONFIG_SYS_IMMR
)->im_cpm
));
203 pcmp
= (pcmconf8xx_t
*)(&(((immap_t
*)CONFIG_SYS_IMMR
)->im_pcmcia
));
205 * Disable PCMCIA buffers (isolate the interface)
206 * and assert RESET signal
208 debug ("Disable PCMCIA buffers and assert RESET\n");
209 reg
= PCMCIA_PGCRX(_slot_
);
210 reg
|= __MY_PCMCIA_GCRX_CXRESET
; /* active high */
211 reg
|= __MY_PCMCIA_GCRX_CXOE
; /* active low */
212 PCMCIA_PGCRX(_slot_
) = reg
;
216 * Configure Port C pins for
217 * 5 Volts Enable and 3 Volts enable,
218 * Turn all power pins to Hi-Z
220 debug ("PCMCIA power OFF\n");
221 cfg_port_B (); /* Enables switch, but all in Hi-Z */
226 case 0: break; /* Switch off */
227 case 33: reg
&= ~TPS2205_VCC3
; break; /* Switch on 3.3V */
228 case 50: reg
&= ~TPS2205_VCC5
; break; /* Switch on 5.0V */
232 /* Checking supported voltages */
234 debug ("PIPR: 0x%x --> %s\n",
236 (pcmp
->pcmc_pipr
& 0x00008000) ? "only 5 V" : "can do 3.3V");
244 if ((reg
& TPS2205_VCC3
) == 0) {
246 } else if ((reg
& TPS2205_VCC5
) == 0) {
251 printf ("PCMCIA powered %s\n", s
);
256 debug ("Enable PCMCIA buffers and stop RESET\n");
257 reg
= PCMCIA_PGCRX(_slot_
);
258 reg
&= ~__MY_PCMCIA_GCRX_CXRESET
; /* active high */
259 reg
&= ~__MY_PCMCIA_GCRX_CXOE
; /* active low */
260 PCMCIA_PGCRX(_slot_
) = reg
;
263 debug ("voltage_set: " PCMCIA_BOARD_MSG
" Slot %c, DONE\n",
268 #endif /* CONFIG_PCMCIA */