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 out_be32(PCMCIA_CTRL, 0);
49 static inline void power_on_5_0(int slot)
51 /* Enable 5V Vccout */
52 out_be32(PCMCIA_CTRL, 2);
55 static inline void power_on_3_3(int slot)
57 /* Enable 3.3V Vccout */
58 out_be32(PCMCIA_CTRL, 1);
63 static inline void power_config(int slot)
65 immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
67 * Configure Port C pins for
68 * 5 Volts Enable and 3 Volts enable
70 clrbits_be16(&immap->im_ioport.iop_pcpar, 0x0002 | 0x0004);
71 clrbits_be16(&immap->im_ioport.iop_pcso, 0x0002 | 0x0004);
74 static inline void power_off(int slot)
76 immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
77 clrbits_be16(&immap->im_ioport.iop_pcdat, 0x0002 | 0x0004);
80 static inline void power_on_5_0(int slot)
82 immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
83 setbits_be16(&immap->im_ioport.iop_pcdat, 0x0004);
84 setbits_be16(&immap->im_ioport.iop_pcdir, 0x0002 | 0x0004);
87 static inline void power_on_3_3(int slot)
89 immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
90 setbits_be16(&immap->im_ioport.iop_pcdat, 0x0002);
91 setbits_be16(&immap->im_ioport.iop_pcdir, 0x0002 | 0x0004);
97 * Function to retrieve the PIPR register, used for debuging purposes.
99 static inline uint32_t debug_get_pipr(void)
103 immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
104 pipr = in_be32(&immap->im_pcmcia.pcmc_pipr);
110 static inline int check_card_is_absent(int slot)
112 immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
113 uint32_t pipr = in_be32(&immap->im_pcmcia.pcmc_pipr);
114 return pipr & (0x18000000 >> (slot << 4));
118 #define NSCU_GCRX_CXOE 0
120 #define NSCU_GCRX_CXOE __MY_PCMCIA_GCRX_CXOE
123 int pcmcia_hardware_enable(int slot)
125 immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
128 debug("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
133 * Configure SIUMCR to enable PCMCIA port B
134 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
138 clrbits_be32(&immap->im_siu_conf.sc_siumcr, SIUMCR_DBGC11);
140 /* Clear interrupt state, and disable interrupts */
141 out_be32(&immap->im_pcmcia.pcmc_pscr, PCMCIA_MASK(slot));
142 clrbits_be32(&immap->im_pcmcia.pcmc_per, PCMCIA_MASK(slot));
145 * Disable interrupts, DMA, and PCMCIA buffers
146 * (isolate the interface) and assert RESET signal
148 debug("Disable PCMCIA buffers and assert RESET\n");
150 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
151 reg |= NSCU_GCRX_CXOE;
153 PCMCIA_PGCRX(slot) = reg;
160 * Make sure there is a card in the slot, then configure the interface.
163 reg = debug_get_pipr();
164 debug("[%d] %s: PIPR(%p)=0x%x\n", __LINE__, __FUNCTION__,
165 &immap->im_pcmcia.pcmc_pipr, reg);
167 if (check_card_is_absent(slot)) {
168 printf (" No Card found\n");
175 mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
176 reg = in_be32(&immap->im_pcmcia.pcmc_pipr);
177 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
179 (reg & PCMCIA_VS1(slot)) ? "n" : "ff",
180 (reg & PCMCIA_VS2(slot)) ? "n" : "ff");
182 if ((reg & mask) == mask) {
184 puts (" 5.0V card found: ");
187 puts (" 3.3V card found: ");
191 /* VCC switch error flag, PCMCIA slot INPACK_ pin */
192 cp->cp_pbdir &= ~(0x0020 | 0x0010);
193 cp->cp_pbpar &= ~(0x0020 | 0x0010);
198 debug("Enable PCMCIA buffers and stop RESET\n");
199 reg = PCMCIA_PGCRX(slot);
200 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
201 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
202 reg &= ~NSCU_GCRX_CXOE;
204 PCMCIA_PGCRX(slot) = reg;
206 udelay(250000); /* some cards need >150 ms to come up :-( */
208 debug("# hardware_enable done\n");
214 #if defined(CONFIG_CMD_PCMCIA)
215 int pcmcia_hardware_disable(int slot)
219 debug("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
221 /* remove all power */
224 debug("Disable PCMCIA buffers and assert RESET\n");
226 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
227 reg |= NSCU_GCRX_CXOE; /* active low */
229 PCMCIA_PGCRX(slot) = reg;
237 int pcmcia_voltage_set(int slot, int vcc, int vpp)
243 debug("voltage_set: " PCMCIA_BOARD_MSG
244 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
245 'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
248 * Disable PCMCIA buffers (isolate the interface)
249 * and assert RESET signal
251 debug("Disable PCMCIA buffers and assert RESET\n");
252 reg = PCMCIA_PGCRX(slot);
253 reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
254 reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
255 reg |= NSCU_GCRX_CXOE; /* active low */
257 PCMCIA_PGCRX(slot) = reg;
260 debug("PCMCIA power OFF\n");
266 case 33: power_on_3_3(slot); break;
267 case 50: power_on_5_0(slot); break;
271 /* Checking supported voltages */
272 pipr = debug_get_pipr();
273 debug("PIPR: 0x%x --> %s\n", pipr,
274 (pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
277 debug("PCMCIA powered at %sV\n", (vcc == 50) ? "5.0" : "3.3");
279 debug("PCMCIA powered down\n");
282 debug("Enable PCMCIA buffers and stop RESET\n");
283 reg = PCMCIA_PGCRX(slot);
284 reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
285 reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
286 reg &= ~NSCU_GCRX_CXOE; /* active low */
288 PCMCIA_PGCRX(slot) = reg;
291 debug("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n", slot+'A');
292 #endif /* CONFIG_NSCU */
296 #endif /* CONFIG_PCMCIA && (CONFIG_TQM8xxL || CONFIG_SVM_SC8xx) */