📄 cmd_pcmcia.c
字号:
#endif
#ifdef CONFIG_FADS
*((uint *)BCSR1) &= ~(BCSR1_PCCVCC0 | BCSR1_PCCVCC1);
#endif
*((uint *)BCSR1) &= ~BCSR1_PCCVPP_MASK;
/* enable new powersettings */
#ifdef CONFIG_ADS
*((uint *)BCSR1) &= ~reg;
#endif
#ifdef CONFIG_FADS
*((uint *)BCSR1) |= reg;
#endif
*((uint *)BCSR1) |= reg << 20;
return 0;
}
#define socket_get(_slot_) PCMCIA_SOCKET_KEY_5V
static int hardware_enable(int slot)
{
*((uint *)BCSR1) &= ~BCSR1_PCCEN;
return 0;
}
static int hardware_disable(int slot)
{
*((uint *)BCSR1) &= ~BCSR1_PCCEN;
return 0;
}
#endif /* (F)ADS */
/* ---------------------------------------------------------------------------- */
/* TQM8xxL Boards by TQ Components */
/* ---------------------------------------------------------------------------- */
#ifdef CONFIG_TQM8xxL
#define PCMCIA_BOARD_MSG "TQM8xxL"
static int hardware_enable(int slot)
{
volatile immap_t *immap;
volatile cpm8xx_t *cp;
volatile pcmconf8xx_t *pcmp;
volatile sysconf8xx_t *sysp;
uint reg, mask;
printf ("hardware_enable: TQM8xxL Slot %c\n", 'A'+slot);
if (slot != 1) {
printf ("## Only Slot B supported for now ##\n");
return (1);
}
immap = (immap_t *)CFG_IMMR;
sysp = (sysconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_siu_conf));
pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
cp = (cpm8xx_t *)(&(((immap_t *)CFG_IMMR)->im_cpm));
/*
* Configure SIUMCR to enable PCMCIA port B
* (VFLS[0:1] are not used for debugging, we connect FRZ# instead)
*/
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_);
/* disable interrupts & DMA */
PCMCIA_PGCRX(_slot_) = 0;
/*
* Disable PCMCIA buffers (isolate the interface)
* and assert RESET signal
*/
printf ("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);
/*
* Configure Port C pins for
* 5 Volts Enable and 3 Volts enable
*/
immap->im_ioport.iop_pcpar &= ~(0x0002 | 0x0004);
immap->im_ioport.iop_pcso &= ~(0x0002 | 0x0004);
/* remove all power */
immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
/*
* Make sure there is a card in the slot, then configure the interface.
*/
printf ("[%d] %s: PIPR(%p)=0x%x\n",__LINE__,__FUNCTION__,&(pcmp->pcmc_pipr),pcmp->pcmc_pipr);udelay(10000);
printf ("[%d] %s: PIPR(%p)=0x%x\n",__LINE__,__FUNCTION__,&(pcmp->pcmc_pipr),pcmp->pcmc_pipr);udelay(10000);
printf ("[%d] %s: PIPR(%p)=0x%x\n",__LINE__,__FUNCTION__,&(pcmp->pcmc_pipr),pcmp->pcmc_pipr);udelay(10000);
if (pcmp->pcmc_pipr & 0x00001800) {
printf ("##### hardware_enable - no card in slot\n");
return (-1);
}
printf ("# hardware_enable - card found\n");
/*
* Power On.
*/
mask = PCMCIA_VS1(slot) | PCMCIA_VS2(slot);
reg = pcmp->pcmc_pipr;
printf ("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) {
immap->im_ioport.iop_pcdat |= 0x0004;
printf ("PCMCIA Power on 5.0 Volt\n");
} else {
immap->im_ioport.iop_pcdat |= 0x0002;
printf ("PCMCIA Power on 3.3 Volt\n");
}
immap->im_ioport.iop_pcdir |= (0x0002 | 0x0004);
/* VCC switch error flag, PCMCIA slot INPACK_ pin */
cp->cp_pbdir &= ~(0x0020 | 0x0010);
cp->cp_pbpar &= ~(0x0020 | 0x0010);
udelay(500000);
printf ("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);
printf ("# hardware_enable done\n");
return (0);
}
static int hardware_disable(int slot)
{
volatile immap_t *immap;
volatile pcmconf8xx_t *pcmp;
u_long reg;
printf ("hardware_disable: TQM8xxL Slot %c\n", 'A'+slot);
if (slot != 1) {
printf ("## Only Slot B supported for now ##\n");
return (1);
}
immap = (immap_t *)CFG_IMMR;
pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
/* remove all power */
immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
/* Configure PCMCIA General Control Register */
PCMCIA_PGCRX(_slot_) = 0;
/*
* Disable PCMCIA buffers (isolate the interface)
*/
printf ("Disable PCMCIA buffers\n");
PCMCIA_PGCRX(_slot_) &= ~__MY_PCMCIA_GCRX_CXOE;
udelay(500);
printf ("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;
return (0);
}
static int voltage_set(int slot, int vcc, int vpp)
{
volatile immap_t *immap;
volatile pcmconf8xx_t *pcmp;
u_long reg;
printf ("voltage_set: TQM8xxL Slot %c, Vcc=%d.%d, Vpp=%d.%d\n",
'A'+slot,vcc/10,vcc%10,vpp/10,vcc%10);
if (slot != 1) {
printf ("## Only Slot B supported for now ##\n");
return (1);
}
immap = (immap_t *)CFG_IMMR;
pcmp = (pcmconf8xx_t *)(&(((immap_t *)CFG_IMMR)->im_pcmcia));
/*
* Disable PCMCIA buffers (isolate the interface)
* and assert RESET signal
*/
printf ("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);
/*
* Configure Port C pins for
* 5 Volts Enable and 3 Volts enable,
* Turn off all power
*/
printf ("PCMCIA power OFF\n");
immap->im_ioport.iop_pcpar &= ~(0x0002 | 0x0004);
immap->im_ioport.iop_pcso &= ~(0x0002 | 0x0004);
immap->im_ioport.iop_pcdat &= ~(0x0002 | 0x0004);
reg = 0;
switch(vcc) {
case 0: break;
case 33: reg |= 0x0002; break;
case 50: reg |= 0x0004; break;
default: goto done;
}
/* Checking supported voltages */
printf ("PIPR: 0x%x --> %s\n", pcmp->pcmc_pipr,
(pcmp->pcmc_pipr & 0x00008000) ? "only 5 V" : "can do 3.3V");
immap->im_ioport.iop_pcdat |= reg;
immap->im_ioport.iop_pcdir |= (0x0002 | 0x0004);
if (reg) {
printf ("PCMCIA powered at %sV\n",(reg&0x0004)?"5.0":"3.3");
} else {
printf ("PCMCIA powered down\n");
}
done:
printf ("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);
printf ("voltage_set: TQM8xxL Slot %c, DONE\n", slot+'A');
return (0);
}
#endif /* TQM8xxL */
/* ---------------------------------------------------------------------------- */
/* End of Board Specific Stuff */
/* ---------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------- */
/* MPC8xx Specific Stuff - should go to MPC8xx directory */
/* ---------------------------------------------------------------------------- */
/*
* Search this table to see if the windowsize is
* supported...
*/
#define M8XX_SIZES_NO 32
static const u_int m8xx_size_to_gray[M8XX_SIZES_NO] =
{ 0x00000001, 0x00000002, 0x00000008, 0x00000004,
0x00000080, 0x00000040, 0x00000010, 0x00000020,
0x00008000, 0x00004000, 0x00001000, 0x00002000,
0x00000100, 0x00000200, 0x00000800, 0x00000400,
0x0fffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0x01000000, 0x02000000, 0xffffffff, 0x04000000,
0x00010000, 0x00020000, 0x00080000, 0x00040000,
0x00800000, 0x00400000, 0x00100000, 0x00200000 };
/* ---------------------------------------------------------------------------- */
static u_int m8xx_get_graycode(u_int size)
{
u_int k;
for (k = 0; k < M8XX_SIZES_NO; k++) {
if(m8xx_size_to_gray[k] == size)
break;
}
if((k == M8XX_SIZES_NO) || (m8xx_size_to_gray[k] == -1))
k = -1;
return k;
}
/* ------------------------------------------------------------------------- */
#if 0
static u_int m8xx_get_speed(u_int ns, u_int is_io)
{
u_int reg, clocks, psst, psl, psht;
if(!ns) {
/*
* We get called with IO maps setup to 0ns
* if not specified by the user.
* They should be 255ns.
*/
if(is_io)
ns = 255;
else
ns = 100; /* fast memory if 0 */
}
/*
* In PSST, PSL, PSHT fields we tell the controller
* timing parameters in CLKOUT clock cycles.
* CLKOUT is the same as GCLK2_50.
*/
/* how we want to adjust the timing - in percent */
#define ADJ 180 /* 80 % longer accesstime - to be sure */
clocks = ((M8XX_BUSFREQ / 1000) * ns) / 1000;
clocks = (clocks * ADJ) / (100*1000);
if(clocks >= PCMCIA_BMT_LIMIT) {
DEBUG(0, "Max access time limit reached\n");
clocks = PCMCIA_BMT_LIMIT-1;
}
psst = clocks / 7; /* setup time */
psht = clocks / 7; /* hold time */
psl = (clocks * 5) / 7; /* strobe length */
psst += clocks - (psst + psht + psl);
reg = psst << 12;
reg |= psl << 7;
reg |= psht << 16;
return reg;
}
#endif
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -