7 #if defined(CONFIG_CMD_PCMCIA)
11 #if defined(CONFIG_CMD_IDE) && defined(CONFIG_IDE_8xx_PCCARD)
17 #define PCMCIA_BOARD_MSG "R360MPI"
19 int pcmcia_hardware_enable(int slot)
21 volatile immap_t *immap;
22 volatile pcmconf8xx_t *pcmp;
23 volatile sysconf8xx_t *sysp;
26 debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
30 immap = (immap_t *)CONFIG_SYS_IMMR;
31 sysp = (sysconf8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_siu_conf));
32 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_pcmcia));
35 * Configure SIUMCR to enable PCMCIA port B
36 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
38 sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
40 /* clear interrupt state, and disable interrupts */
41 pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
42 pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
45 * Disable interrupts, DMA, and PCMCIA buffers
46 * (isolate the interface) and assert RESET signal
48 debug ("Disable PCMCIA buffers and assert RESET\n");
50 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
51 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
52 PCMCIA_PGCRX(_slot_) = reg;
56 * Configure Ports A, B & C pins for
57 * 5 Volts Enable and 3 Volts enable
59 immap->im_ioport.iop_pcpar &= ~(0x0400);
60 immap->im_ioport.iop_pcso &= ~(0x0400);/*
61 immap->im_ioport.iop_pcdir |= 0x0400;*/
63 immap->im_ioport.iop_papar &= ~(0x0200);/*
64 immap->im_ioport.iop_padir |= 0x0200;*/
66 immap->im_ioport.iop_pbpar &= ~(0xC000);
67 immap->im_ioport.iop_pbdir &= ~(0xC000);
69 /* remove all power */
71 immap->im_ioport.iop_pcdat |= 0x0400;
72 immap->im_ioport.iop_padat |= 0x0200;
75 * Make sure there is a card in the slot, then configure the interface.
78 debug ("[%d] %s: PIPR(%p)=0x%x\n",
79 __LINE__,__FUNCTION__,
80 &(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
81 if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
82 printf (" No Card found\n");
89 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
90 reg = pcmp->pcmc_pipr;
91 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
93 (reg&PCMCIA_VS1(slot))?"n":"ff",
94 (reg&PCMCIA_VS2(slot))?"n":"ff");
95 if ((reg & mask) == mask) {
96 immap->im_ioport.iop_pcdat &= ~(0x4000);
97 puts (" 5.0V card found: ");
99 immap->im_ioport.iop_padat &= ~(0x0002);
100 puts (" 3.3V card found: ");
102 immap->im_ioport.iop_pcdir |= 0x0400;
103 immap->im_ioport.iop_padir |= 0x0200;
105 /* VCC switch error flag, PCMCIA slot INPACK_ pin */
106 cp->cp_pbdir &= ~(0x0020 | 0x0010);
107 cp->cp_pbpar &= ~(0x0020 | 0x0010);
110 debug ("Enable PCMCIA buffers and stop RESET\n");
111 reg = PCMCIA_PGCRX(_slot_);
112 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
113 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
114 PCMCIA_PGCRX(_slot_) = reg;
116 udelay(250000); /* some cards need >150 ms to come up :-( */
118 debug ("# hardware_enable done\n");
124 #if defined(CONFIG_CMD_PCMCIA)
125 int pcmcia_hardware_disable(int slot)
127 volatile immap_t *immap;
130 debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
132 immap = (immap_t *)CONFIG_SYS_IMMR;
134 /* remove all power */
135 immap->im_ioport.iop_pcdat |= 0x0400;
136 immap->im_ioport.iop_padat |= 0x0200;
138 /* Configure PCMCIA General Control Register */
139 debug ("Disable PCMCIA buffers and assert RESET\n");
141 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
142 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
143 PCMCIA_PGCRX(_slot_) = reg;
152 int pcmcia_voltage_set(int slot, int vcc, int vpp)
154 volatile immap_t *immap;
155 volatile pcmconf8xx_t *pcmp;
158 debug ("voltage_set: "
160 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
161 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
163 immap = (immap_t *)CONFIG_SYS_IMMR;
164 pcmp = (pcmconf8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_pcmcia));
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;
177 * Configure Ports A & C pins for
178 * 5 Volts Enable and 3 Volts enable,
181 debug ("PCMCIA power OFF\n");
182 immap->im_ioport.iop_pcpar &= ~(0x0400);
183 immap->im_ioport.iop_pcso &= ~(0x0400);/*
184 immap->im_ioport.iop_pcdir |= 0x0400;*/
186 immap->im_ioport.iop_papar &= ~(0x0200);/*
187 immap->im_ioport.iop_padir |= 0x0200;*/
189 immap->im_ioport.iop_pcdat |= 0x0400;
190 immap->im_ioport.iop_padat |= 0x0200;
195 case 33: reg |= 0x0200; break;
196 case 50: reg |= 0x0400; break;
200 /* Checking supported voltages */
202 debug ("PIPR: 0x%x --> %s\n",
204 (pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
207 immap->im_ioport.iop_pcdat &= !reg;
209 immap->im_ioport.iop_padat &= !reg;
210 immap->im_ioport.iop_pcdir |= 0x0200;
211 immap->im_ioport.iop_padir |= 0x0400;
213 debug ("PCMCIA powered at %sV\n",
214 (reg&0x0400) ? "5.0" : "3.3");
216 debug ("PCMCIA powered down\n");
220 debug ("Enable PCMCIA buffers and stop RESET\n");
221 reg = PCMCIA_PGCRX(_slot_);
222 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
223 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
224 PCMCIA_PGCRX(_slot_) = reg;
227 debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
232 #endif /* CCONFIG_PCMCIA */