7 #if defined(CONFIG_CMD_PCMCIA)
11 #if defined(CONFIG_CMD_IDE) && defined(CONFIG_IDE_8xx_PCCARD)
17 #define PCMCIA_BOARD_MSG "KUP"
19 #define KUP4K_PCMCIA_B_3V3 (0x00020000)
21 int pcmcia_hardware_enable(int slot)
23 volatile cpm8xx_t *cp;
24 volatile pcmconf8xx_t *pcmp;
25 volatile sysconf8xx_t *sysp;
28 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
32 sysp = (sysconf8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_siu_conf));
33 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_pcmcia));
34 cp = (cpm8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_cpm));
37 * Configure SIUMCR to enable PCMCIA port B
38 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
40 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
42 /* clear interrupt state, and disable interrupts */
43 pcmp->pcmc_pscr = PCMCIA_MASK(slot);
44 pcmp->pcmc_per &= ~PCMCIA_MASK(slot);
47 * Disable interrupts, DMA, and PCMCIA buffers
48 * (isolate the interface) and assert RESET signal
50 debug ("Disable PCMCIA buffers and assert RESET\n");
52 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
53 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
54 PCMCIA_PGCRX(slot) = reg;
58 * Configure Port B pins for
61 if (slot) { /* Slot A is built-in */
62 cp->cp_pbdir |= KUP4K_PCMCIA_B_3V3;
63 cp->cp_pbpar &= ~KUP4K_PCMCIA_B_3V3;
64 /* remove all power */
65 cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3; /* active low */
68 * Make sure there is a card in the slot, then configure the interface.
71 debug ("[%d] %s: PIPR(%p)=0x%x\n",
72 __LINE__,__FUNCTION__,
73 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
74 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
75 printf (" No Card found\n");
82 printf("%s Slot %c:", slot ? "" : "\n", 'A' + slot);
83 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
84 reg = pcmp->pcmc_pipr;
85 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
87 (reg&PCMCIA_VS1(slot))?"n":"ff",
88 (reg&PCMCIA_VS2(slot))?"n":"ff");
89 if ((reg & mask) == mask) {
90 puts (" 5.0V card found: NOT SUPPORTED !!!\n");
93 cp->cp_pbdat &= ~KUP4K_PCMCIA_B_3V3;
94 puts (" 3.3V card found: ");
97 /* VCC switch error flag, PCMCIA slot INPACK_ pin */
98 cp->cp_pbdir &= ~(0x0020 | 0x0010);
99 cp->cp_pbpar &= ~(0x0020 | 0x0010);
102 debug ("Enable PCMCIA buffers and stop RESET\n");
103 reg = PCMCIA_PGCRX(slot);
104 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
105 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
106 PCMCIA_PGCRX(slot) = reg;
108 udelay(250000); /* some cards need >150 ms to come up :-( */
110 debug ("# hardware_enable done\n");
116 #if defined(CONFIG_CMD_PCMCIA)
117 int pcmcia_hardware_disable(int slot)
119 volatile immap_t *immap;
120 volatile cpm8xx_t *cp;
121 volatile pcmconf8xx_t *pcmp;
124 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
126 immap = (immap_t *)CONFIG_SYS_IMMR;
127 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_pcmcia));
128 cp = (cpm8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_cpm));
130 /* remove all power */
132 cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3;
134 /* Configure PCMCIA General Control Register */
135 debug ("Disable PCMCIA buffers and assert RESET\n");
137 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
138 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
139 PCMCIA_PGCRX(slot) = reg;
148 int pcmcia_voltage_set(int slot, int vcc, int vpp)
150 volatile cpm8xx_t *cp;
151 volatile pcmconf8xx_t *pcmp;
154 debug ("voltage_set: " \
156 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
157 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
159 if (!slot) /* Slot A is not configurable */
162 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_pcmcia));
163 cp = (cpm8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_cpm));
166 * Disable PCMCIA buffers (isolate the interface)
167 * and assert RESET signal
169 debug ("Disable PCMCIA buffers and assert RESET\n");
170 reg = PCMCIA_PGCRX(slot);
171 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
172 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
173 PCMCIA_PGCRX(slot) = reg;
176 debug ("PCMCIA power OFF\n");
178 * Configure Port B pins for
181 cp->cp_pbdir |= KUP4K_PCMCIA_B_3V3;
182 cp->cp_pbpar &= ~KUP4K_PCMCIA_B_3V3;
183 /* remove all power */
184 cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3; /* active low */
189 cp->cp_pbdat &= ~KUP4K_PCMCIA_B_3V3;
190 debug ("PCMCIA powered at 3.3V\n");
193 debug ("PCMCIA: 5Volt vcc not supported\n");
196 puts("PCMCIA: vcc not supported");
200 /* Checking supported voltages */
202 debug ("PIPR: 0x%x --> %s\n",
204 (pcmp->pcmc_pipr & (0x80000000 >> (slot << 4)))
205 ? "only 5 V --> NOT SUPPORTED"
209 debug ("Enable PCMCIA buffers and stop RESET\n");
210 reg = PCMCIA_PGCRX(slot);
211 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
212 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
213 PCMCIA_PGCRX(slot) = reg;
216 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
221 #endif /* CONFIG_PCMCIA */