8 #if defined(CONFIG_CMD_PCMCIA)
12 #if defined(CONFIG_CMD_IDE) && defined(CONFIG_IDE_8xx_PCCARD)
18 #define PCMCIA_BOARD_MSG "LWMON"
20 /* #define's for MAX1604 Power Switch */
21 #define MAX1604_OP_SUS 0x80
22 #define MAX1604_VCCBON 0x40
23 #define MAX1604_VCC_35 0x20
24 #define MAX1604_VCCBHIZ 0x10
25 #define MAX1604_VPPBON 0x08
26 #define MAX1604_VPPBPBPGM 0x04
27 #define MAX1604_VPPBHIZ 0x02
30 int pcmcia_hardware_enable(int slot
)
32 volatile pcmconf8xx_t
*pcmp
;
33 volatile sysconf8xx_t
*sysp
;
38 debug ("hardware_enable: " PCMCIA_BOARD_MSG
" Slot %c\n", 'A'+slot
);
40 /* Switch on PCMCIA port in PIC register 0x60 */
41 reg
= pic_read (0x60);
42 debug ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__
, reg
);
44 /* reg |= 0x08; Vpp not needed */
45 pic_write (0x60, reg
);
47 reg
= pic_read (0x60);
48 printf ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__
, reg
);
52 sysp
= (sysconf8xx_t
*)(&(((immap_t
*)CONFIG_SYS_IMMR
)->im_siu_conf
));
53 pcmp
= (pcmconf8xx_t
*)(&(((immap_t
*)CONFIG_SYS_IMMR
)->im_pcmcia
));
56 * Configure SIUMCR to enable PCMCIA port B
57 * (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
59 sysp
->sc_siumcr
&= ~SIUMCR_DBGC11
; /* set DBGC to 00 */
61 /* clear interrupt state, and disable interrupts */
62 pcmp
->pcmc_pscr
= PCMCIA_MASK(_slot_
);
63 pcmp
->pcmc_per
&= ~PCMCIA_MASK(_slot_
);
66 * Disable interrupts, DMA, and PCMCIA buffers
67 * (isolate the interface) and assert RESET signal
69 debug ("Disable PCMCIA buffers and assert RESET\n");
71 reg
|= __MY_PCMCIA_GCRX_CXRESET
; /* active high */
72 reg
|= __MY_PCMCIA_GCRX_CXOE
; /* active low */
73 PCMCIA_PGCRX(_slot_
) = reg
;
77 * Make sure there is a card in the slot, then configure the interface.
80 debug ("[%d] %s: PIPR(%p)=0x%x\n",
81 __LINE__
,__FUNCTION__
,
82 &(pcmp
->pcmc_pipr
),pcmp
->pcmc_pipr
);
83 if (pcmp
->pcmc_pipr
& (0x18000000 >> (slot
<< 4))) {
84 printf (" No Card found\n");
91 mask
= PCMCIA_VS1(slot
) | PCMCIA_VS2(slot
);
92 reg
= pcmp
->pcmc_pipr
;
93 debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
95 (reg
&PCMCIA_VS1(slot
))?"n":"ff",
96 (reg
&PCMCIA_VS2(slot
))?"n":"ff");
97 if ((reg
& mask
) == mask
) {
98 val
= 0; /* VCCB3/5 = 0 ==> use Vx = 5.0 V */
99 puts (" 5.0V card found: ");
101 val
= MAX1604_VCC_35
; /* VCCB3/5 = 1 ==> use Vy = 3.3 V */
102 puts (" 3.3V card found: ");
106 val
|= MAX1604_OP_SUS
| MAX1604_VCCBON
;
108 i2c_write (CONFIG_SYS_I2C_POWER_A_ADDR
, 0, 0, &val
, 1);
112 debug ("Enable PCMCIA buffers and stop RESET\n");
113 reg
= PCMCIA_PGCRX(_slot_
);
114 reg
&= ~__MY_PCMCIA_GCRX_CXRESET
; /* active high */
115 reg
&= ~__MY_PCMCIA_GCRX_CXOE
; /* active low */
116 PCMCIA_PGCRX(_slot_
) = reg
;
118 udelay(250000); /* some cards need >150 ms to come up :-( */
120 debug ("# hardware_enable done\n");
126 #if defined(CONFIG_CMD_PCMCIA)
127 int pcmcia_hardware_disable(int slot
)
129 volatile immap_t
*immap
;
130 volatile pcmconf8xx_t
*pcmp
;
134 debug ("hardware_disable: " PCMCIA_BOARD_MSG
" Slot %c\n", 'A'+slot
);
136 immap
= (immap_t
*)CONFIG_SYS_IMMR
;
137 pcmp
= (pcmconf8xx_t
*)(&(((immap_t
*)CONFIG_SYS_IMMR
)->im_pcmcia
));
139 /* remove all power, put output in high impedance state */
140 val
= MAX1604_VCCBHIZ
| MAX1604_VPPBHIZ
;
141 i2c_init (CONFIG_SYS_I2C_SPEED
, CONFIG_SYS_I2C_SLAVE
);
142 i2c_write (CONFIG_SYS_I2C_POWER_A_ADDR
, 0, 0, &val
, 1);
144 /* Configure PCMCIA General Control Register */
145 debug ("Disable PCMCIA buffers and assert RESET\n");
147 reg
|= __MY_PCMCIA_GCRX_CXRESET
; /* active high */
148 reg
|= __MY_PCMCIA_GCRX_CXOE
; /* active low */
149 PCMCIA_PGCRX(_slot_
) = reg
;
151 /* Switch off PCMCIA port in PIC register 0x60 */
152 reg
= pic_read (0x60);
153 debug ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__
, reg
);
156 pic_write (0x60, reg
);
158 reg
= pic_read (0x60);
159 printf ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__
, reg
);
168 int pcmcia_voltage_set(int slot
, int vcc
, int vpp
)
170 volatile pcmconf8xx_t
*pcmp
;
174 debug ("voltage_set: "
176 " Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
177 'A'+slot
, vcc
/10, vcc
%10, vpp
/10, vcc
%10);
179 pcmp
= (pcmconf8xx_t
*)(&(((immap_t
*)CONFIG_SYS_IMMR
)->im_pcmcia
));
181 * Disable PCMCIA buffers (isolate the interface)
182 * and assert RESET signal
184 debug ("Disable PCMCIA buffers and assert RESET\n");
185 reg
= PCMCIA_PGCRX(_slot_
);
186 reg
|= __MY_PCMCIA_GCRX_CXRESET
; /* active high */
187 reg
|= __MY_PCMCIA_GCRX_CXOE
; /* active low */
188 PCMCIA_PGCRX(_slot_
) = reg
;
192 * Turn off all power (switch to high impedance)
194 debug ("PCMCIA power OFF\n");
195 val
= MAX1604_VCCBHIZ
| MAX1604_VPPBHIZ
;
197 i2c_write (CONFIG_SYS_I2C_POWER_A_ADDR
, 0, 0, &val
, 1);
202 case 33: val
= MAX1604_VCC_35
; break;
207 /* Checking supported voltages */
209 debug ("PIPR: 0x%x --> %s\n",
211 (pcmp
->pcmc_pipr
& 0x00008000) ? "only 5 V" : "can do 3.3V");
213 i2c_write (CONFIG_SYS_I2C_POWER_A_ADDR
, 0, 0, &val
, 1);
215 debug ("PCMCIA powered at %sV\n",
216 (val
& MAX1604_VCC_35
) ? "3.3" : "5.0");
218 debug ("PCMCIA powered down\n");
222 debug ("Enable PCMCIA buffers and stop RESET\n");
223 reg
= PCMCIA_PGCRX(_slot_
);
224 reg
&= ~__MY_PCMCIA_GCRX_CXRESET
; /* active high */
225 reg
&= ~__MY_PCMCIA_GCRX_CXOE
; /* active low */
226 PCMCIA_PGCRX(_slot_
) = reg
;
229 debug ("voltage_set: " PCMCIA_BOARD_MSG
" Slot %c, DONE\n",
234 #endif /* CONFIG_PCMCIA */