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_VIRTLAB2)
26 #define PCMCIA_BOARD_MSG "Virtlab2"
27 #elif defined(CONFIG_TQM8xxL)
28 #define PCMCIA_BOARD_MSG "TQM8xxL"
31 #if defined(CONFIG_NSCU)
33 static inline void power_config(int slot) {}
34 static inline void power_off(int slot) {}
35 static inline void power_on_5_0(int slot) {}
36 static inline void power_on_3_3(int slot) {}
38 #elif defined(CONFIG_VIRTLAB2)
40 static inline void power_config(int slot) {}
42 static inline void power_off(int slot)
44 volatile unsigned __iomem *addr;
45 addr = (volatile unsigned __iomem *)PCMCIA_CTRL;
50 static inline void power_on_5_0(int slot)
52 volatile unsigned __iomem *addr;
53 addr = (volatile unsigned __iomem *)PCMCIA_CTRL;
55 /* Enable 5V Vccout */
59 static inline void power_on_3_3(int slot)
61 volatile unsigned __iomem *addr;
62 addr = (volatile unsigned __iomem *)PCMCIA_CTRL;
64 /* Enable 3.3V Vccout */
70 static inline void power_config(int slot)
72 immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
74 * Configure Port C pins for
75 * 5 Volts Enable and 3 Volts enable
77 clrbits_be16(&immap->im_ioport.iop_pcpar, 0x0002 | 0x0004);
78 clrbits_be16(&immap->im_ioport.iop_pcso, 0x0002 | 0x0004);
81 static inline void power_off(int slot)
83 immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
84 clrbits_be16(&immap->im_ioport.iop_pcdat, 0x0002 | 0x0004);
87 static inline void power_on_5_0(int slot)
89 immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
90 setbits_be16(&immap->im_ioport.iop_pcdat, 0x0004);
91 setbits_be16(&immap->im_ioport.iop_pcdir, 0x0002 | 0x0004);
94 static inline void power_on_3_3(int slot)
96 immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
97 setbits_be16(&immap->im_ioport.iop_pcdat, 0x0002);
98 setbits_be16(&immap->im_ioport.iop_pcdir, 0x0002 | 0x0004);
104 * Function to retrieve the PIPR register, used for debuging purposes.
106 static inline uint32_t debug_get_pipr(void)
110 immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
111 pipr = in_be32(&immap->im_pcmcia.pcmc_pipr);
117 static inline int check_card_is_absent(int slot)
119 immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
120 uint32_t pipr = in_be32(&immap->im_pcmcia.pcmc_pipr);
121 return pipr & (0x18000000 >> (slot << 4));
125 #define NSCU_GCRX_CXOE 0
127 #define NSCU_GCRX_CXOE __MY_PCMCIA_GCRX_CXOE
130 int pcmcia_hardware_enable(int slot)
132 immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
135 debug("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
140 * Configure SIUMCR to enable PCMCIA port B
141 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
145 clrbits_be32(&immap->im_siu_conf.sc_siumcr, SIUMCR_DBGC11);
147 /* Clear interrupt state, and disable interrupts */
148 out_be32(&immap->im_pcmcia.pcmc_pscr, PCMCIA_MASK(slot));
149 clrbits_be32(&immap->im_pcmcia.pcmc_per, PCMCIA_MASK(slot));
152 * Disable interrupts, DMA, and PCMCIA buffers
153 * (isolate the interface) and assert RESET signal
155 debug("Disable PCMCIA buffers and assert RESET\n");
157 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
158 reg |= NSCU_GCRX_CXOE;
160 PCMCIA_PGCRX(slot) = reg;
167 * Make sure there is a card in the slot, then configure the interface.
170 reg = debug_get_pipr();
171 debug("[%d] %s: PIPR(%p)=0x%x\n", __LINE__, __FUNCTION__,
172 &immap->im_pcmcia.pcmc_pipr, reg);
174 if (check_card_is_absent(slot)) {
175 printf (" No Card found\n");
182 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
183 reg = in_be32(&immap->im_pcmcia.pcmc_pipr);
184 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
186 (reg & PCMCIA_VS1(slot)) ? "n" : "ff",
187 (reg & PCMCIA_VS2(slot)) ? "n" : "ff");
189 if ((reg & mask) == mask) {
191 puts (" 5.0V card found: ");
194 puts (" 3.3V card found: ");
198 /* VCC switch error flag, PCMCIA slot INPACK_ pin */
199 cp->cp_pbdir &= ~(0x0020 | 0x0010);
200 cp->cp_pbpar &= ~(0x0020 | 0x0010);
205 debug("Enable PCMCIA buffers and stop RESET\n");
206 reg = PCMCIA_PGCRX(slot);
207 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
208 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
209 reg &= ~NSCU_GCRX_CXOE;
211 PCMCIA_PGCRX(slot) = reg;
213 udelay(250000); /* some cards need >150 ms to come up :-( */
215 debug("# hardware_enable done\n");
221 #if defined(CONFIG_CMD_PCMCIA)
222 int pcmcia_hardware_disable(int slot)
226 debug("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
228 /* remove all power */
231 debug("Disable PCMCIA buffers and assert RESET\n");
233 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
234 reg |= NSCU_GCRX_CXOE; /* active low */
236 PCMCIA_PGCRX(slot) = reg;
244 int pcmcia_voltage_set(int slot, int vcc, int vpp)
250 debug("voltage_set: " PCMCIA_BOARD_MSG
251 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
252 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
255 * Disable PCMCIA buffers (isolate the interface)
256 * and assert RESET signal
258 debug("Disable PCMCIA buffers and assert RESET\n");
259 reg = PCMCIA_PGCRX(slot);
260 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
261 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
262 reg |= NSCU_GCRX_CXOE; /* active low */
264 PCMCIA_PGCRX(slot) = reg;
267 debug("PCMCIA power OFF\n");
273 case 33: power_on_3_3(slot); break;
274 case 50: power_on_5_0(slot); break;
278 /* Checking supported voltages */
279 pipr = debug_get_pipr();
280 debug("PIPR: 0x%x --> %s\n", pipr,
281 (pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
284 debug("PCMCIA powered at %sV\n", (vcc == 50) ? "5.0" : "3.3");
286 debug("PCMCIA powered down\n");
289 debug("Enable PCMCIA buffers and stop RESET\n");
290 reg = PCMCIA_PGCRX(slot);
291 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
292 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
293 reg &= ~NSCU_GCRX_CXOE; /* active low */
295 PCMCIA_PGCRX(slot) = reg;
298 debug("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n", slot+'A');
299 #endif /* CONFIG_NSCU */
303 #endif /* CONFIG_PCMCIA && CONFIG_TQM8xxL */