⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sysmpc107pci.c

📁 Vxworks的bsp软件开发包(基于wrPpmc74xx)
💻 C
字号:
/* syMpc107Pci.c - Motorola MPC107 PCI Bridge Chip routines *//* Copyright 1995-2001 Wind River Systems. *//*modification history--------------------01a,12may01,g_h created*//*DESCRIPTIONMotorola MPC107 PCI bridge driver.INCLUDE FILES: sysMpc107Pci.h*//* includes */#include "vxWorks.h"#include "memLib.h"#include "drv/pci/mpc105.h"#include "sysMpc107Pci.h"/* defines *//* globals *//* forward declarations *//* externals *//***************************************************************************** sysMpc107PciInit - Additional setup for MPC107** This routine setup the MPC107 PCI bridge** RETURNS: N/A** SEE ALSO: sysMpc107CfgWrite(), sysMpc107CfgRead()*/void sysMpc107PciInit    (    void    )    {    ULONG tmp;    ULONG eumbBar;    /* position the Embedded Utilities Block where we want it */    eumbBar = EUMB_BASE_ADRS;    sysMpc107CfgWrite (EUMBBAR,eumbBar,REG_32BIT);    /*     * CLKDCR - disable all PCI CLK outputs.     */    tmp = sysMpc107CfgRead (0x74,REG_16BIT);    tmp &= 0x83FF;    tmp |= 0x7C00;    sysMpc107CfgWrite (0x74,tmp,REG_16BIT);    /*     * ODCR - alter PCI signal drive strengths.          */    tmp = sysMpc107CfgRead (0x73,REG_8BIT);    tmp &= 0xF3;    tmp |= 0x04;    sysMpc107CfgWrite (0x73,tmp,REG_8BIT);    /*     * Set Flash Write Enable in PICR1 register             */    tmp = sysMpc107CfgRead (0xA8,REG_32BIT);    tmp |= PICR1_MCP_EN;    tmp |= PICR1_FLASH_WR_EN;    sysMpc107CfgWrite (0xA8,tmp,REG_32BIT);    /*     * Set PCI Arbiter Control     */    tmp = sysMpc107CfgRead (0x46,REG_16BIT);    tmp &= 0x8000; /* preserve power up default for PCIARB enable */    tmp |= 0x8000; /* this is needed for JTAG debugging */    tmp |= 0x0080; /* MPC107 high priority */    tmp |= 0x2000; /* park bus with 107 */    sysMpc107CfgWrite (0x46,tmp,REG_16BIT);    /*     * Turn on some error reporting bits     */    tmp = 0xFFFFFFFFUL;    sysMpc107CfgWrite (0xC0, tmp, REG_32BIT);    sysMpc107CfgWrite (0xC4, tmp, REG_32BIT);    return;    }/***************************************************************************** sysMpc107CfgWrite - write to PCI Config Space.** This function write to a specified PCI Config Space address.** RETURNS: N/A** SEE ALSO: sysMpc107PciInit(), sysMpc107CfgRead()*/void sysMpc107CfgWrite    (    UINT32 offset,     UINT32 data,     int    width    )    {    sysMpc107PciOutLong (PCI_ADDRESS_REGISTER, 0x80000000 | (offset & ~3));        switch (width) 	 {         case 4:	     sysMpc107PciOutLong (PCI_DATA_REGISTER, data);             break;         case 2:	     sysMpc107PciOutWord (PCI_DATA_REGISTER + (offset & 3), data);	     break;         default:	     sysMpc107PciOutByte (PCI_DATA_REGISTER + (offset & 3), data);         }    }/***************************************************************************** sysMpc107CfgRead - reads from PCI Config Space.** This function reads from a specified PCI Config Space address.** RETURNS: value readen from address.** SEE ALSO: sysMpc107PciInit(), sysMpc107CfgWrite()*/UINT32 sysMpc107CfgRead    (    UINT32 offset,     int    width     )    {    UINT32 data;    sysMpc107PciOutLong (PCI_ADDRESS_REGISTER, 0x80000000 | (offset & ~3));    switch (width)          {	 case 4:	     data = sysMpc107PciInLong (PCI_DATA_REGISTER);	     break;         case 2:             data = sysMpc107PciInWord (PCI_DATA_REGISTER + (offset & 3));             break;         default:	     data = sysMpc107PciInByte (PCI_DATA_REGISTER + (offset & 3));         }    return data;    }/***************************************************************************** sysMpc107PciOutByte - writes a byte to PCI Config Space.** This function writes a byte to a specified PCI Config Space address.** RETURNS: N/A** SEE ALSO: sysMpc107PciInByte(), sysMpc107PciOutWord(), sysMpc107PciInWord(),*           sysMpc107PciOutLong(), sysMpc107PciOutLong()*/void sysMpc107PciOutByte    (    ULONG       address,       /* I/O address to write to */    UCHAR       data            /* data to write */    )    {    *(UCHAR *)address = data;      EIEIO;    }                                                /***************************************************************************** sysMpc107PciInByte - reads a byte from PCI Config Space.** This function reads a byte from a specified PCI Config Space address.** RETURNS: byte from address.** SEE ALSO: sysMpc107PciOutByte(), sysMpc107PciOutWord(), sysMpc107PciInWord(),*           sysMpc107PciInLong(), sysMpc107PciOutLong()*/UCHAR sysMpc107PciInByte    (    ULONG       address         /* I/O address to read from */    )    {    UCHAR retVal;    retVal = *(UCHAR *)address;    return (retVal);    }/***************************************************************************** sysMpc107PciOutWord - writes a word (16-bit big-endian) to PCI Config Space.** This function writes a word to a specified PCI Config Space (little-endian)* address.** RETURNS: N/A** SEE ALSO: sysMpc107PciInByte(), sysMpc107PciOutByte(), sysMpc107PciInWord(),*           sysMpc107PciInLong(), sysMpc107PciOutLong()*/void sysMpc107PciOutWord    (    ULONG       address,       /* I/O address to write to */    UINT16      data           /* data to write */    )    {    *(UINT16 *)address = BYTE_SWAP_16_BIT(data);      EIEIO;    }/***************************************************************************** sysMpc107PciInWord - reads a word (16-bit big-endian) from PCI Config Space.** This function reads a word from a specified PCI Config Space (little-endian)* address.** RETURNS: word (16-bit big-endian) from address.** SEE ALSO: sysMpc107PciInByte(), sysMpc107PciOutByte(), sysMpc107PciOutWord(),*           sysMpc107PciInLong(), sysMpc107PciOutLong()*/USHORT sysMpc107PciInWord    (    ULONG       address         /* I/O address to read from */    )    {    USHORT retVal;    retVal = BYTE_SWAP_16_BIT(*(USHORT *)address);    return (retVal);    }/***************************************************************************** sysMpc107PciOutLong - writes a long (32-bit big-endian) to PCI Config Space.** This function writes a long to a specified PCI Config Space (little-endian)* address.** RETURNS: N/A** SEE ALSO: sysMpc107PciInByte(), sysMpc107PciOutByte(), sysMpc107PciOutWord(),*           sysMpc107PciInWord(), sysMpc107PciInLong()*/void sysMpc107PciOutLong    (    ULONG address,        /* I/O address to write to */    ULONG    data            /* data to write */    )    {       *(ULONG *)address = LONGSWAP(data);     EIEIO;    }                                                /***************************************************************************** sysMpc107PciInLong - reads a long (32-bit big-endian) from PCI Config Space.** This function reads a long from a specified PCI Config Space (little-endian)* address.** RETURNS: long (32-bit big-endian) from address.** SEE ALSO: sysMpc107PciInByte(), sysMpc107PciOutByte(), sysMpc107PciOutWord(),*           sysMpc107PciInWord(), sysMpc107PciOutLong()*/ULONG sysMpc107PciInLong    (    ULONG       address         /* I/O address to read from */    )    {    ULONG retVal;    retVal = LONGSWAP(*(ULONG *)address);    EIEIO;    return (retVal);    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -