1 /* -------------------------------------------------------------------- */
2 /* TQM8xxL Boards by TQ Components */
3 /* SC8xx Boards by SinoVee Microsystems */
4 /* -------------------------------------------------------------------- */
14 #if defined(CONFIG_CMD_PCMCIA)
18 #if defined(CONFIG_CMD_IDE) && defined(CONFIG_IDE_8xx_PCCARD)
22 #if defined(CONFIG_PCMCIA) \
23 && defined(CONFIG_TQM8xxL)
25 #if defined(CONFIG_TQM8xxL)
26 #define PCMCIA_BOARD_MSG "TQM8xxL"
29 static inline void power_config(int slot)
31 immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
33 * Configure Port C pins for
34 * 5 Volts Enable and 3 Volts enable
36 clrbits_be16(&immap->im_ioport.iop_pcpar, 0x0002 | 0x0004);
37 clrbits_be16(&immap->im_ioport.iop_pcso, 0x0002 | 0x0004);
40 static inline void power_off(int slot)
42 immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
43 clrbits_be16(&immap->im_ioport.iop_pcdat, 0x0002 | 0x0004);
46 static inline void power_on_5_0(int slot)
48 immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
49 setbits_be16(&immap->im_ioport.iop_pcdat, 0x0004);
50 setbits_be16(&immap->im_ioport.iop_pcdir, 0x0002 | 0x0004);
53 static inline void power_on_3_3(int slot)
55 immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
56 setbits_be16(&immap->im_ioport.iop_pcdat, 0x0002);
57 setbits_be16(&immap->im_ioport.iop_pcdir, 0x0002 | 0x0004);
61 * Function to retrieve the PIPR register, used for debuging purposes.
63 static inline uint32_t debug_get_pipr(void)
67 immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
68 pipr = in_be32(&immap->im_pcmcia.pcmc_pipr);
74 static inline int check_card_is_absent(int slot)
76 immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
77 uint32_t pipr = in_be32(&immap->im_pcmcia.pcmc_pipr);
78 return pipr & (0x18000000 >> (slot << 4));
81 #define NSCU_GCRX_CXOE __MY_PCMCIA_GCRX_CXOE
83 int pcmcia_hardware_enable(int slot)
85 immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
88 debug("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
93 * Configure SIUMCR to enable PCMCIA port B
94 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
98 clrbits_be32(&immap->im_siu_conf.sc_siumcr, SIUMCR_DBGC11);
100 /* Clear interrupt state, and disable interrupts */
101 out_be32(&immap->im_pcmcia.pcmc_pscr, PCMCIA_MASK(slot));
102 clrbits_be32(&immap->im_pcmcia.pcmc_per, PCMCIA_MASK(slot));
105 * Disable interrupts, DMA, and PCMCIA buffers
106 * (isolate the interface) and assert RESET signal
108 debug("Disable PCMCIA buffers and assert RESET\n");
110 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
111 reg |= NSCU_GCRX_CXOE;
113 PCMCIA_PGCRX(slot) = reg;
120 * Make sure there is a card in the slot, then configure the interface.
123 reg = debug_get_pipr();
124 debug("[%d] %s: PIPR(%p)=0x%x\n", __LINE__, __FUNCTION__,
125 &immap->im_pcmcia.pcmc_pipr, reg);
127 if (check_card_is_absent(slot)) {
128 printf (" No Card found\n");
135 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
136 reg = in_be32(&immap->im_pcmcia.pcmc_pipr);
137 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
139 (reg & PCMCIA_VS1(slot)) ? "n" : "ff",
140 (reg & PCMCIA_VS2(slot)) ? "n" : "ff");
142 if ((reg & mask) == mask) {
144 puts (" 5.0V card found: ");
147 puts (" 3.3V card found: ");
151 /* VCC switch error flag, PCMCIA slot INPACK_ pin */
152 cp->cp_pbdir &= ~(0x0020 | 0x0010);
153 cp->cp_pbpar &= ~(0x0020 | 0x0010);
158 debug("Enable PCMCIA buffers and stop RESET\n");
159 reg = PCMCIA_PGCRX(slot);
160 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
161 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
162 reg &= ~NSCU_GCRX_CXOE;
164 PCMCIA_PGCRX(slot) = reg;
166 udelay(250000); /* some cards need >150 ms to come up :-( */
168 debug("# hardware_enable done\n");
174 #if defined(CONFIG_CMD_PCMCIA)
175 int pcmcia_hardware_disable(int slot)
179 debug("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
181 /* remove all power */
184 debug("Disable PCMCIA buffers and assert RESET\n");
186 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
187 reg |= NSCU_GCRX_CXOE; /* active low */
189 PCMCIA_PGCRX(slot) = reg;
197 int pcmcia_voltage_set(int slot, int vcc, int vpp)
202 debug("voltage_set: " PCMCIA_BOARD_MSG
203 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
204 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
207 * Disable PCMCIA buffers (isolate the interface)
208 * and assert RESET signal
210 debug("Disable PCMCIA buffers and assert RESET\n");
211 reg = PCMCIA_PGCRX(slot);
212 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
213 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
214 reg |= NSCU_GCRX_CXOE; /* active low */
216 PCMCIA_PGCRX(slot) = reg;
219 debug("PCMCIA power OFF\n");
225 case 33: power_on_3_3(slot); break;
226 case 50: power_on_5_0(slot); break;
230 /* Checking supported voltages */
231 pipr = debug_get_pipr();
232 debug("PIPR: 0x%x --> %s\n", pipr,
233 (pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
236 debug("PCMCIA powered at %sV\n", (vcc == 50) ? "5.0" : "3.3");
238 debug("PCMCIA powered down\n");
241 debug("Enable PCMCIA buffers and stop RESET\n");
242 reg = PCMCIA_PGCRX(slot);
243 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
244 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
245 reg &= ~NSCU_GCRX_CXOE; /* active low */
247 PCMCIA_PGCRX(slot) = reg;
250 debug("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n", slot+'A');
254 #endif /* CONFIG_PCMCIA && CONFIG_TQM8xxL */