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 immap_t *immap;
33
volatile cpm8xx_t *cp;
34
volatile pcmconf8xx_t *pcmp;
35
volatile sysconf8xx_t *sysp;
40
debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
42
/* Switch on PCMCIA port in PIC register 0x60 */
43
reg = pic_read (0x60);
44
debug ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
46
/* reg |= 0x08; Vpp not needed */
47
pic_write (0x60, reg);
49
reg = pic_read (0x60);
50
printf ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
54
immap = (immap_t *)CONFIG_SYS_IMMR;
55
sysp = (sysconf8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_siu_conf));
56
pcmp = (pcmconf8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_pcmcia));
57
cp = (cpm8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_cpm));
60
* Configure SIUMCR to enable PCMCIA port B
61
* (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
63
sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
65
/* clear interrupt state, and disable interrupts */
66
pcmp->pcmc_pscr = PCMCIA_MASK(_slot_);
67
pcmp->pcmc_per &= ~PCMCIA_MASK(_slot_);
70
* Disable interrupts, DMA, and PCMCIA buffers
71
* (isolate the interface) and assert RESET signal
73
debug ("Disable PCMCIA buffers and assert RESET\n");
75
reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
76
reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
77
PCMCIA_PGCRX(_slot_) = reg;
81
* Make sure there is a card in the slot, then configure the interface.
84
debug ("[%d] %s: PIPR(%p)=0x%x\n",
85
__LINE__,__FUNCTION__,
86
&(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
87
if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
88
printf (" No Card found\n");
95
mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
96
reg = pcmp->pcmc_pipr;
97
debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
99
(reg&PCMCIA_VS1(slot))?"n":"ff",
100
(reg&PCMCIA_VS2(slot))?"n":"ff");
101
if ((reg & mask) == mask) {
102
val = 0; /* VCCB3/5 = 0 ==> use Vx = 5.0 V */
103
puts (" 5.0V card found: ");
105
val = MAX1604_VCC_35; /* VCCB3/5 = 1 ==> use Vy = 3.3 V */
106
puts (" 3.3V card found: ");
110
val |= MAX1604_OP_SUS | MAX1604_VCCBON;
111
i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
112
i2c_write (CONFIG_SYS_I2C_POWER_A_ADDR, 0, 0, &val, 1);
116
debug ("Enable PCMCIA buffers and stop RESET\n");
117
reg = PCMCIA_PGCRX(_slot_);
118
reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
119
reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
120
PCMCIA_PGCRX(_slot_) = reg;
122
udelay(250000); /* some cards need >150 ms to come up :-( */
124
debug ("# hardware_enable done\n");
130
#if defined(CONFIG_CMD_PCMCIA)
131
int pcmcia_hardware_disable(int slot)
133
volatile immap_t *immap;
134
volatile pcmconf8xx_t *pcmp;
138
debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
140
immap = (immap_t *)CONFIG_SYS_IMMR;
141
pcmp = (pcmconf8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_pcmcia));
143
/* remove all power, put output in high impedance state */
144
val = MAX1604_VCCBHIZ | MAX1604_VPPBHIZ;
145
i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
146
i2c_write (CONFIG_SYS_I2C_POWER_A_ADDR, 0, 0, &val, 1);
148
/* Configure PCMCIA General Control Register */
149
debug ("Disable PCMCIA buffers and assert RESET\n");
151
reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
152
reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
153
PCMCIA_PGCRX(_slot_) = reg;
155
/* Switch off PCMCIA port in PIC register 0x60 */
156
reg = pic_read (0x60);
157
debug ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
160
pic_write (0x60, reg);
162
reg = pic_read (0x60);
163
printf ("[%d] PIC read: reg_60 = 0x%02x\n", __LINE__, reg);
172
int pcmcia_voltage_set(int slot, int vcc, int vpp)
174
volatile immap_t *immap;
175
volatile pcmconf8xx_t *pcmp;
179
debug ("voltage_set: "
181
" Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
182
'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
184
immap = (immap_t *)CONFIG_SYS_IMMR;
185
pcmp = (pcmconf8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_pcmcia));
187
* Disable PCMCIA buffers (isolate the interface)
188
* and assert RESET signal
190
debug ("Disable PCMCIA buffers and assert RESET\n");
191
reg = PCMCIA_PGCRX(_slot_);
192
reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
193
reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
194
PCMCIA_PGCRX(_slot_) = reg;
198
* Turn off all power (switch to high impedance)
200
debug ("PCMCIA power OFF\n");
201
val = MAX1604_VCCBHIZ | MAX1604_VPPBHIZ;
202
i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
203
i2c_write (CONFIG_SYS_I2C_POWER_A_ADDR, 0, 0, &val, 1);
208
case 33: val = MAX1604_VCC_35; break;
213
/* Checking supported voltages */
215
debug ("PIPR: 0x%x --> %s\n",
217
(pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
219
i2c_write (CONFIG_SYS_I2C_POWER_A_ADDR, 0, 0, &val, 1);
221
debug ("PCMCIA powered at %sV\n",
222
(val & MAX1604_VCC_35) ? "3.3" : "5.0");
224
debug ("PCMCIA powered down\n");
228
debug ("Enable PCMCIA buffers and stop RESET\n");
229
reg = PCMCIA_PGCRX(_slot_);
230
reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
231
reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
232
PCMCIA_PGCRX(_slot_) = reg;
235
debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
240
#endif /* CONFIG_PCMCIA */