2006-07-10 21:07:28 +00:00
|
|
|
#include <common.h>
|
|
|
|
#include <mpc8xx.h>
|
|
|
|
#include <pcmcia.h>
|
|
|
|
|
|
|
|
#undef CONFIG_PCMCIA
|
|
|
|
|
2007-07-09 23:31:28 +00:00
|
|
|
#if defined(CONFIG_CMD_PCMCIA)
|
2006-07-10 21:07:28 +00:00
|
|
|
#define CONFIG_PCMCIA
|
|
|
|
#endif
|
|
|
|
|
2007-07-09 23:31:28 +00:00
|
|
|
#if defined(CONFIG_CMD_IDE) && defined(CONFIG_IDE_8xx_PCCARD)
|
2006-07-10 21:07:28 +00:00
|
|
|
#define CONFIG_PCMCIA
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_PCMCIA
|
|
|
|
|
|
|
|
#define PCMCIA_BOARD_MSG "KUP"
|
|
|
|
|
|
|
|
#define KUP4K_PCMCIA_B_3V3 (0x00020000)
|
|
|
|
|
|
|
|
int pcmcia_hardware_enable(int slot)
|
|
|
|
{
|
|
|
|
volatile cpm8xx_t *cp;
|
|
|
|
volatile pcmconf8xx_t *pcmp;
|
|
|
|
volatile sysconf8xx_t *sysp;
|
|
|
|
uint reg, mask;
|
|
|
|
|
|
|
|
debug ("hardware_enable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
|
|
|
|
|
|
|
|
udelay(10000);
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
sysp = (sysconf8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_siu_conf));
|
|
|
|
pcmp = (pcmconf8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_pcmcia));
|
|
|
|
cp = (cpm8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_cpm));
|
2006-07-10 21:07:28 +00:00
|
|
|
|
|
|
|
/*
|
2011-11-04 15:55:25 +00:00
|
|
|
* Configure SIUMCR to enable PCMCIA port B
|
|
|
|
* (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
|
|
|
|
*/
|
2006-07-10 21:07:28 +00:00
|
|
|
sysp->sc_siumcr &= ~SIUMCR_DBGC11; /* set DBGC to 00 */
|
|
|
|
|
|
|
|
/* clear interrupt state, and disable interrupts */
|
|
|
|
pcmp->pcmc_pscr = PCMCIA_MASK(slot);
|
|
|
|
pcmp->pcmc_per &= ~PCMCIA_MASK(slot);
|
|
|
|
|
|
|
|
/*
|
2011-11-04 15:55:25 +00:00
|
|
|
* Disable interrupts, DMA, and PCMCIA buffers
|
|
|
|
* (isolate the interface) and assert RESET signal
|
|
|
|
*/
|
2006-07-10 21:07:28 +00:00
|
|
|
debug ("Disable PCMCIA buffers and assert RESET\n");
|
|
|
|
reg = 0;
|
|
|
|
reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
|
|
|
|
reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
|
|
|
|
PCMCIA_PGCRX(slot) = reg;
|
|
|
|
udelay(2500);
|
|
|
|
|
|
|
|
/*
|
2011-11-04 15:55:25 +00:00
|
|
|
* Configure Port B pins for
|
|
|
|
* 3 Volts enable
|
|
|
|
*/
|
2006-07-10 21:07:28 +00:00
|
|
|
if (slot) { /* Slot A is built-in */
|
|
|
|
cp->cp_pbdir |= KUP4K_PCMCIA_B_3V3;
|
|
|
|
cp->cp_pbpar &= ~KUP4K_PCMCIA_B_3V3;
|
|
|
|
/* remove all power */
|
|
|
|
cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3; /* active low */
|
|
|
|
}
|
|
|
|
/*
|
2011-11-04 15:55:25 +00:00
|
|
|
* Make sure there is a card in the slot, then configure the interface.
|
|
|
|
*/
|
2006-07-10 21:07:28 +00:00
|
|
|
udelay(10000);
|
|
|
|
debug ("[%d] %s: PIPR(%p)=0x%x\n",
|
|
|
|
__LINE__,__FUNCTION__,
|
|
|
|
&(pcmp->pcmc_pipr),pcmp->pcmc_pipr);
|
|
|
|
if (pcmp->pcmc_pipr & (0x18000000 >> (slot << 4))) {
|
|
|
|
printf (" No Card found\n");
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2011-11-04 15:55:25 +00:00
|
|
|
* Power On.
|
|
|
|
*/
|
2006-07-10 21:07:28 +00:00
|
|
|
printf("%s Slot %c:", slot ? "" : "\n", 'A' + slot);
|
|
|
|
mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
|
|
|
|
reg = pcmp->pcmc_pipr;
|
|
|
|
debug ("PIPR: 0x%x ==> VS1=o%s, VS2=o%s\n",
|
|
|
|
reg,
|
|
|
|
(reg&PCMCIA_VS1(slot))?"n":"ff",
|
|
|
|
(reg&PCMCIA_VS2(slot))?"n":"ff");
|
|
|
|
if ((reg & mask) == mask) {
|
|
|
|
puts (" 5.0V card found: NOT SUPPORTED !!!\n");
|
|
|
|
} else {
|
|
|
|
if(slot)
|
|
|
|
cp->cp_pbdat &= ~KUP4K_PCMCIA_B_3V3;
|
|
|
|
puts (" 3.3V card found: ");
|
|
|
|
}
|
|
|
|
#if 0
|
|
|
|
/* VCC switch error flag, PCMCIA slot INPACK_ pin */
|
|
|
|
cp->cp_pbdir &= ~(0x0020 | 0x0010);
|
|
|
|
cp->cp_pbpar &= ~(0x0020 | 0x0010);
|
|
|
|
udelay(500000);
|
|
|
|
#endif
|
|
|
|
debug ("Enable PCMCIA buffers and stop RESET\n");
|
|
|
|
reg = PCMCIA_PGCRX(slot);
|
|
|
|
reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
|
|
|
|
reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
|
|
|
|
PCMCIA_PGCRX(slot) = reg;
|
|
|
|
|
|
|
|
udelay(250000); /* some cards need >150 ms to come up :-( */
|
|
|
|
|
|
|
|
debug ("# hardware_enable done\n");
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-07-09 23:31:28 +00:00
|
|
|
#if defined(CONFIG_CMD_PCMCIA)
|
2006-07-10 21:07:28 +00:00
|
|
|
int pcmcia_hardware_disable(int slot)
|
|
|
|
{
|
|
|
|
volatile immap_t *immap;
|
|
|
|
volatile cpm8xx_t *cp;
|
|
|
|
volatile pcmconf8xx_t *pcmp;
|
|
|
|
u_long reg;
|
|
|
|
|
|
|
|
debug ("hardware_disable: " PCMCIA_BOARD_MSG " Slot %c\n", 'A'+slot);
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
immap = (immap_t *)CONFIG_SYS_IMMR;
|
|
|
|
pcmp = (pcmconf8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_pcmcia));
|
|
|
|
cp = (cpm8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_cpm));
|
2006-07-10 21:07:28 +00:00
|
|
|
|
|
|
|
/* remove all power */
|
|
|
|
if (slot)
|
|
|
|
cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3;
|
|
|
|
|
|
|
|
/* Configure PCMCIA General Control Register */
|
|
|
|
debug ("Disable PCMCIA buffers and assert RESET\n");
|
|
|
|
reg = 0;
|
|
|
|
reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
|
|
|
|
reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
|
|
|
|
PCMCIA_PGCRX(slot) = reg;
|
|
|
|
|
|
|
|
udelay(10000);
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
2007-07-10 15:48:22 +00:00
|
|
|
#endif
|
2006-07-10 21:07:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
int pcmcia_voltage_set(int slot, int vcc, int vpp)
|
|
|
|
{
|
|
|
|
volatile cpm8xx_t *cp;
|
|
|
|
volatile pcmconf8xx_t *pcmp;
|
|
|
|
u_long reg;
|
|
|
|
|
|
|
|
debug ("voltage_set: " \
|
|
|
|
PCMCIA_BOARD_MSG \
|
|
|
|
" Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
|
|
|
|
'A'+slot, vcc/10, vcc%10, vpp/10, vcc%10);
|
|
|
|
|
|
|
|
if (!slot) /* Slot A is not configurable */
|
|
|
|
return 0;
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
pcmp = (pcmconf8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_pcmcia));
|
|
|
|
cp = (cpm8xx_t *)(&(((immap_t *)CONFIG_SYS_IMMR)->im_cpm));
|
2006-07-10 21:07:28 +00:00
|
|
|
|
|
|
|
/*
|
2011-11-04 15:55:25 +00:00
|
|
|
* Disable PCMCIA buffers (isolate the interface)
|
|
|
|
* and assert RESET signal
|
|
|
|
*/
|
2006-07-10 21:07:28 +00:00
|
|
|
debug ("Disable PCMCIA buffers and assert RESET\n");
|
|
|
|
reg = PCMCIA_PGCRX(slot);
|
|
|
|
reg |= __MY_PCMCIA_GCRX_CXRESET; /* active high */
|
|
|
|
reg |= __MY_PCMCIA_GCRX_CXOE; /* active low */
|
|
|
|
PCMCIA_PGCRX(slot) = reg;
|
|
|
|
udelay(500);
|
|
|
|
|
|
|
|
debug ("PCMCIA power OFF\n");
|
|
|
|
/*
|
2011-11-04 15:55:25 +00:00
|
|
|
* Configure Port B pins for
|
|
|
|
* 3 Volts enable
|
|
|
|
*/
|
2006-07-10 21:07:28 +00:00
|
|
|
cp->cp_pbdir |= KUP4K_PCMCIA_B_3V3;
|
|
|
|
cp->cp_pbpar &= ~KUP4K_PCMCIA_B_3V3;
|
|
|
|
/* remove all power */
|
|
|
|
cp->cp_pbdat |= KUP4K_PCMCIA_B_3V3; /* active low */
|
|
|
|
|
|
|
|
switch(vcc) {
|
2008-05-20 14:00:29 +00:00
|
|
|
case 0: break;
|
2006-07-10 21:07:28 +00:00
|
|
|
case 33:
|
|
|
|
cp->cp_pbdat &= ~KUP4K_PCMCIA_B_3V3;
|
|
|
|
debug ("PCMCIA powered at 3.3V\n");
|
|
|
|
break;
|
|
|
|
case 50:
|
|
|
|
debug ("PCMCIA: 5Volt vcc not supported\n");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
puts("PCMCIA: vcc not supported");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
udelay(10000);
|
|
|
|
/* Checking supported voltages */
|
|
|
|
|
|
|
|
debug ("PIPR: 0x%x --> %s\n",
|
|
|
|
pcmp->pcmc_pipr,
|
|
|
|
(pcmp->pcmc_pipr & (0x80000000 >> (slot << 4)))
|
|
|
|
? "only 5 V --> NOT SUPPORTED"
|
|
|
|
: "can do 3.3V");
|
|
|
|
|
|
|
|
|
|
|
|
debug ("Enable PCMCIA buffers and stop RESET\n");
|
|
|
|
reg = PCMCIA_PGCRX(slot);
|
|
|
|
reg &= ~__MY_PCMCIA_GCRX_CXRESET; /* active high */
|
|
|
|
reg &= ~__MY_PCMCIA_GCRX_CXOE; /* active low */
|
|
|
|
PCMCIA_PGCRX(slot) = reg;
|
|
|
|
udelay(500);
|
|
|
|
|
|
|
|
debug ("voltage_set: " PCMCIA_BOARD_MSG " Slot %c, DONE\n",
|
|
|
|
slot+'A');
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* CONFIG_PCMCIA */
|