7 #if defined(CONFIG_CMD_PCMCIA)
11 #if defined(CONFIG_CMD_IDE) && defined(CONFIG_IDE_8xx_PCCARD)
17 #define PCMCIA_BOARD_MSG "C2MON"
19 static void cfg_ports (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 C for TPS2211 PC-Card Power-Interface Switch
31 * Switch off all voltages, assert shutdown
33 sreg = immap->im_ioport.iop_pcdat;
34 sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1); /* VAVPP => Hi-Z */
35 sreg &= ~(TPS2211_VCCD0 | TPS2211_VCCD1); /* 3V and 5V off */
36 immap->im_ioport.iop_pcdat = sreg;
38 immap->im_ioport.iop_pcpar &= ~(TPS2211_OUTPUTS);
39 immap->im_ioport.iop_pcdir |= TPS2211_OUTPUTS;
41 debug ("Set Port C: PAR: %04x DIR: %04x DAT: %04x\n",
42 immap->im_ioport.iop_pcpar,
43 immap->im_ioport.iop_pcdir,
44 immap->im_ioport.iop_pcdat);
47 * Configure Port B for TPS2211 PC-Card Power-Interface Switch
49 * Over-Current Input only
51 cp->cp_pbpar &= ~(TPS2211_INPUTS);
52 cp->cp_pbdir &= ~(TPS2211_INPUTS);
54 debug ("Set Port B: PAR: %08x DIR: %08x DAT: %08x\n",
55 cp->cp_pbpar, cp->cp_pbdir, cp->cp_pbdat);
58 int pcmcia_hardware_enable(int slot)
60 volatile immap_t *immap;
61 volatile cpm8xx_t *cp;
62 volatile pcmconf8xx_t *pcmp;
63 volatile sysconf8xx_t *sysp;
68 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
72 immap = (immap_t *)CONFIG_SYS_IMMR;
73 sysp = (sysconf8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_siu_conf));
74 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_pcmcia));
75 cp = (cpm8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_cpm));
77 /* Configure Ports for TPS2211A PC-Card Power-Interface Switch */
81 * Configure SIUMCR to enable PCMCIA port B
82 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
84 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
86 /* clear interrupt state, and disable interrupts */
87 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
88 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
91 * Disable interrupts, DMA, and PCMCIA buffers
92 * (isolate the interface) and assert RESET signal
94 debug ("Disable PCMCIA buffers and assert RESET\n");
96 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
97 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
98 PCMCIA_PGCRX(_slot_) = reg;
102 * Make sure there is a card in the slot, then configure the interface.
105 debug ("[%d] %s: PIPR(%p)=0x%x\n",
106 __LINE__,__FUNCTION__,
107 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
108 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
109 printf (" No Card found\n");
114 * Power On: Set VAVCC to 3.3V or 5V, set VAVPP to Hi-Z
116 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
117 pipr = pcmp->pcmc_pipr;
118 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
120 (reg&PCMCIA_VS1(slot))?"n":"ff",
121 (reg&PCMCIA_VS2(slot))?"n":"ff");
123 sreg = immap->im_ioport.iop_pcdat;
124 if ((pipr & mask) == mask) {
125 sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1 | /* VAVPP => Hi-Z */
126 TPS2211_VCCD1); /* 5V on */
127 sreg &= ~(TPS2211_VCCD0); /* 3V off */
128 puts (" 5.0V card found: ");
130 sreg |= (TPS2211_VPPD0 | TPS2211_VPPD1 | /* VAVPP => Hi-Z */
131 TPS2211_VCCD0); /* 3V on */
132 sreg &= ~(TPS2211_VCCD1); /* 5V off */
133 puts (" 3.3V card found: ");
136 debug ("\nPC DAT: %04x -> 3.3V %s 5.0V %s\n",
138 ( (sreg & TPS2211_VCCD0) && !(sreg & TPS2211_VCCD1)) ? "on" : "off",
139 (!(sreg & TPS2211_VCCD0) && (sreg & TPS2211_VCCD1)) ? "on" : "off"
142 immap->im_ioport.iop_pcdat = sreg;
144 /* Wait 500 ms; use this to check for over-current */
145 for (i=0; i<5000; ++i) {
146 if ((cp->cp_pbdat & TPS2211_OC) == 0) {
147 printf (" *** Overcurrent - Safety shutdown ***\n");
148 immap->im_ioport.iop_pcdat &= ~(TPS2211_VCCD0|TPS2211_VCCD1);
154 debug ("Enable PCMCIA buffers and stop RESET\n");
155 reg = PCMCIA_PGCRX(_slot_);
156 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
157 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
158 PCMCIA_PGCRX(_slot_) = reg;
160 udelay(250000); /* some cards need >150 ms to come up :-( */
162 debug ("# hardware_enable done\n");
168 #if defined(CONFIG_CMD_PCMCIA)
169 int pcmcia_hardware_disable(int slot)
171 volatile immap_t *immap;
172 volatile cpm8xx_t *cp;
173 volatile pcmconf8xx_t *pcmp;
176 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
178 immap = (immap_t *)CONFIG_SYS_IMMR;
179 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_pcmcia));
181 /* Configure PCMCIA General Control Register */
182 debug ("Disable PCMCIA buffers and assert RESET\n");
184 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
185 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
186 PCMCIA_PGCRX(_slot_) = reg;
188 /* ALl voltages off / Hi-Z */
189 immap->im_ioport.iop_pcdat |= (TPS2211_VPPD0 | TPS2211_VPPD1 |
190 TPS2211_VCCD0 | TPS2211_VCCD1 );
199 int pcmcia_voltage_set(int slot, int vcc, int vpp)
201 volatile immap_t *immap;
202 volatile pcmconf8xx_t *pcmp;
206 debug ("voltage_set: "
208 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
209 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
211 immap = (immap_t *)CONFIG_SYS_IMMR;
212 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_pcmcia));
214 * Disable PCMCIA buffers (isolate the interface)
215 * and assert RESET signal
217 debug ("Disable PCMCIA buffers and assert RESET\n");
218 reg = PCMCIA_PGCRX(_slot_);
219 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
220 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
221 PCMCIA_PGCRX(_slot_) = reg;
225 * Configure Port C pins for
226 * 5 Volts Enable and 3 Volts enable,
227 * Turn all power pins to Hi-Z
229 debug ("PCMCIA power OFF\n");
230 cfg_ports (); /* Enables switch, but all in Hi-Z */
232 sreg = immap->im_ioport.iop_pcdat;
233 sreg |= TPS2211_VPPD0 | TPS2211_VPPD1; /* VAVPP always Hi-Z */
236 case 0: break; /* Switch off */
237 case 33: sreg |= TPS2211_VCCD0; /* Switch on 3.3V */
238 sreg &= ~TPS2211_VCCD1;
240 case 50: sreg &= ~TPS2211_VCCD0; /* Switch on 5.0V */
241 sreg |= TPS2211_VCCD1;
246 /* Checking supported voltages */
248 debug ("PIPR: 0x%x --> %s\n",
250 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
252 immap->im_ioport.iop_pcdat = sreg;
258 if ((sreg & TPS2211_VCCD0) && !(sreg & TPS2211_VCCD1)) {
260 } else if (!(sreg & TPS2211_VCCD0) && (sreg & TPS2211_VCCD1)) {
265 printf ("PCMCIA powered %s\n", s);
270 debug ("Enable PCMCIA buffers and stop RESET\n");
271 reg = PCMCIA_PGCRX(_slot_);
272 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
273 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
274 PCMCIA_PGCRX(_slot_) = reg;
277 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
282 #endif /* CONFIG_PCMCIA */