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) || defined(CONFIG_SVM_SC8xx))
25 #if defined(CONFIG_VIRTLAB2)
26 #define PCMCIA_BOARD_MSG "Virtlab2"
27 #elif defined(CONFIG_TQM8xxL)
28 #define PCMCIA_BOARD_MSG "TQM8xxL"
29 #elif defined(CONFIG_SVM_SC8xx)
30 #define PCMCIA_BOARD_MSG "SC8xx"
33 #if defined(CONFIG_NSCU)
35 static inline void power_config(int slot) {}
36 static inline void power_off(int slot) {}
37 static inline void power_on_5_0(int slot) {}
38 static inline void power_on_3_3(int slot) {}
40 #elif defined(CONFIG_VIRTLAB2)
42 static inline void power_config(int slot) {}
44 static inline void power_off(int slot)
46 volatile unsigned __iomem *addr;
47 addr = (volatile unsigned __iomem *)PCMCIA_CTRL;
52 static inline void power_on_5_0(int slot)
54 volatile unsigned __iomem *addr;
55 addr = (volatile unsigned __iomem *)PCMCIA_CTRL;
57 /* Enable 5V Vccout */
61 static inline void power_on_3_3(int slot)
63 volatile unsigned __iomem *addr;
64 addr = (volatile unsigned __iomem *)PCMCIA_CTRL;
66 /* Enable 3.3V Vccout */
72 static inline void power_config(int slot)
74 immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
76 * Configure Port C pins for
77 * 5 Volts Enable and 3 Volts enable
79 clrbits_be16(&immap->im_ioport.iop_pcpar, 0x0002 | 0x0004);
80 clrbits_be16(&immap->im_ioport.iop_pcso, 0x0002 | 0x0004);
83 static inline void power_off(int slot)
85 immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
86 clrbits_be16(&immap->im_ioport.iop_pcdat, 0x0002 | 0x0004);
89 static inline void power_on_5_0(int slot)
91 immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
92 setbits_be16(&immap->im_ioport.iop_pcdat, 0x0004);
93 setbits_be16(&immap->im_ioport.iop_pcdir, 0x0002 | 0x0004);
96 static inline void power_on_3_3(int slot)
98 immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
99 setbits_be16(&immap->im_ioport.iop_pcdat, 0x0002);
100 setbits_be16(&immap->im_ioport.iop_pcdir, 0x0002 | 0x0004);
106 * Function to retrieve the PIPR register, used for debuging purposes.
108 static inline uint32_t debug_get_pipr(void)
112 immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
113 pipr = in_be32(&immap->im_pcmcia.pcmc_pipr);
119 static inline int check_card_is_absent(int slot)
121 immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
122 uint32_t pipr = in_be32(&immap->im_pcmcia.pcmc_pipr);
123 return pipr & (0x18000000 >> (slot << 4));
127 #define NSCU_GCRX_CXOE 0
129 #define NSCU_GCRX_CXOE __MY_PCMCIA_GCRX_CXOE
132 int pcmcia_hardware_enable(int slot)
134 immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
137 debug("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
142 * Configure SIUMCR to enable PCMCIA port B
143 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
147 clrbits_be32(&immap->im_siu_conf.sc_siumcr, SIUMCR_DBGC11);
149 /* Clear interrupt state, and disable interrupts */
150 out_be32(&immap->im_pcmcia.pcmc_pscr, PCMCIA_MASK(slot));
151 clrbits_be32(&immap->im_pcmcia.pcmc_per, PCMCIA_MASK(slot));
154 * Disable interrupts, DMA, and PCMCIA buffers
155 * (isolate the interface) and assert RESET signal
157 debug("Disable PCMCIA buffers and assert RESET\n");
159 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
160 reg |= NSCU_GCRX_CXOE;
162 PCMCIA_PGCRX(slot) = reg;
169 * Make sure there is a card in the slot, then configure the interface.
172 reg = debug_get_pipr();
173 debug("[%d] %s: PIPR(%p)=0x%x\n", __LINE__, __FUNCTION__,
174 &immap->im_pcmcia.pcmc_pipr, reg);
176 if (check_card_is_absent(slot)) {
177 printf (" No Card found\n");
184 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
185 reg = in_be32(&immap->im_pcmcia.pcmc_pipr);
186 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
188 (reg & PCMCIA_VS1(slot)) ? "n" : "ff",
189 (reg & PCMCIA_VS2(slot)) ? "n" : "ff");
191 if ((reg & mask) == mask) {
193 puts (" 5.0V card found: ");
196 puts (" 3.3V card found: ");
200 /* VCC switch error flag, PCMCIA slot INPACK_ pin */
201 cp->cp_pbdir &= ~(0x0020 | 0x0010);
202 cp->cp_pbpar &= ~(0x0020 | 0x0010);
207 debug("Enable PCMCIA buffers and stop RESET\n");
208 reg = PCMCIA_PGCRX(slot);
209 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
210 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
211 reg &= ~NSCU_GCRX_CXOE;
213 PCMCIA_PGCRX(slot) = reg;
215 udelay(250000); /* some cards need >150 ms to come up :-( */
217 debug("# hardware_enable done\n");
223 #if defined(CONFIG_CMD_PCMCIA)
224 int pcmcia_hardware_disable(int slot)
228 debug("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
230 /* remove all power */
233 debug("Disable PCMCIA buffers and assert RESET\n");
235 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
236 reg |= NSCU_GCRX_CXOE; /* active low */
238 PCMCIA_PGCRX(slot) = reg;
246 int pcmcia_voltage_set(int slot, int vcc, int vpp)
252 debug("voltage_set: " PCMCIA_BOARD_MSG
253 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
254 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
257 * Disable PCMCIA buffers (isolate the interface)
258 * and assert RESET signal
260 debug("Disable PCMCIA buffers and assert RESET\n");
261 reg = PCMCIA_PGCRX(slot);
262 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
263 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
264 reg |= NSCU_GCRX_CXOE; /* active low */
266 PCMCIA_PGCRX(slot) = reg;
269 debug("PCMCIA power OFF\n");
275 case 33: power_on_3_3(slot); break;
276 case 50: power_on_5_0(slot); break;
280 /* Checking supported voltages */
281 pipr = debug_get_pipr();
282 debug("PIPR: 0x%x --> %s\n", pipr,
283 (pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
286 debug("PCMCIA powered at %sV\n", (vcc == 50) ? "5.0" : "3.3");
288 debug("PCMCIA powered down\n");
291 debug("Enable PCMCIA buffers and stop RESET\n");
292 reg = PCMCIA_PGCRX(slot);
293 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
294 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
295 reg &= ~NSCU_GCRX_CXOE; /* active low */
297 PCMCIA_PGCRX(slot) = reg;
300 debug("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n", slot+'A');
301 #endif /* CONFIG_NSCU */
305 #endif /* CONFIG_PCMCIA && (CONFIG_TQM8xxL || CONFIG_SVM_SC8xx) */