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

📄 pcidrv.c

📁 DM6437评估版BIOS下的PCI驱动程序
💻 C
📖 第 1 页 / 共 4 页
字号:
#include <linux/config.h>
#include <linux/module.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/pci.h>
#include <linux/delay.h>
#include <linux/fs.h>
#include <linux/init.h>
#include <linux/ioport.h>
#include <asm/uaccess.h>
#include <linux/interrupt.h>
#include <asm/irq.h>

/** ============================================================================
 *  @macro  Data types
 *
 *  @desc   Basic data types
 *  ============================================================================
 */
typedef signed char         Int8 ;      /*  8 bit value */
typedef signed short int    Int16 ;     /* 16 bit value */
typedef signed long  int    Int32 ;     /* 32 bit value */

typedef unsigned char       Uint8 ;     /*  8 bit value */
typedef unsigned short int  Uint16 ;    /* 16 bit value */
typedef unsigned long  int  Uint32 ;    /* 32 bit value */

typedef float               Real32 ;    /* 32 bit value */
typedef double              Real64 ;    /* 64 bit value */

typedef short int           Bool ;      /* 16 bit value */

typedef char                Char8 ;     /*  8 bit value */
typedef short               Char16 ;    /* 16 bit value */

typedef unsigned char       Uchar8 ;    /*  8 bit value */
typedef unsigned short      Uchar16 ;   /* 16 bit value */

#define Void                void
typedef void *              Pvoid ;

typedef Char8 *             Pstr ;
typedef Uchar8 *            Pustr ;

#define LPSC_DDR    (13)
/** ============================================================================
 *  @const  PCI_TI_VENDOR
 *
 *  @desc   TI Vendor ID.
 *  ============================================================================
 */
#define PCI_TI_VENDOR   0x104c

/** ============================================================================
 *  @const  PCI_TI_DEVICE
 *
 *  @desc   PCI Device ID.
 *  ============================================================================
 */
#define PCI_TI_DEVICE   0xB001

/** ============================================================================
 *  @const   DM64LCPCI_DEVREG_BASE
 *
 *  @desc    Base address of Device config registers.
 *  ============================================================================
 */
#define DM64LCPCI_DEVREG_BASE      0x01C40000

/** ============================================================================
 *  @const   DM64LCPCI_PLLREG_BASE
 *
 *  @desc    Base address of PLL0 registers.
 *  ============================================================================
 */
#define DM64LCPCI_PLL0REG_BASE      0x01C40800

/** ============================================================================
 *  @const   DM64LCPCI_PLLREG_BASE
 *
 *  @desc    Base address of PLL1 registers.
 *  ============================================================================
 */
#define DM64LCPCI_PLL1REG_BASE      0x01C40C00

/** ============================================================================
 *  @const   DM64LCPCI_EDMAREG_BASE
 *
 *  @desc    Base address of EDMA registers.
 *  ============================================================================
 */
#define DM64LCPCI_EDMAREG_BASE      0x01C00000

/** ============================================================================
 *  @const   DM64LCPCI_DDRREG_BASE
 *
 *  @desc    Base address of DDR PHY registers.
 *  ============================================================================
 */
#define DM64LCPCI_DDRREG_BASE       0x20000000

/** ============================================================================
 *  @const   DM64LCPCI_PSCREG_BASE
 *
 *  @desc    Base address of PSC registers.
 *  ============================================================================
 */
#define DM64LCPCI_PSCREG_BASE       0x01C41000

/** ============================================================================
 *  @const   DM64LCPCI_PCIREG_BASE
 *
 *  @desc    Base address of PCI backend registers.
 *  ============================================================================
 */
#define DM64LCPCI_PCIREG_BASE       0x01C1A000

/** ============================================================================
 *  @const   DM64LCPCI_SOFTINT0_MASK
 *
 *  @desc    Mask for generating soft int0 (DSP->GPP)
 *  ============================================================================
 */
//#define DM64LCPCI_SOFTINT0_MASK       0xffffffff
#define DM64LCPCI_SOFTINT0_MASK    0x80000000
/** ============================================================================
 *  @const   DM64LCPCI_SOFTINT1_MASK
 *
 *  @desc    Mask for generating soft int1 (GPP->DSP)
 *  ============================================================================
 */
#define DM64LCPCI_SOFTINT1_MASK       0x02000000

/** ============================================================================
 *  @const   DM64LCPCI_LRESET_MASK
 *
 *  @desc    Mask for reseting/releasing GEM.
 *  ============================================================================
 */
#define DM64LCPCI_LRESET_MASK         0x00000100

/** ============================================================================
 *  @const   DM64LCPCI_INTSTATUS_MASK
 *
 *  @desc    Bitmask for Interrupt status (DSP->GPP)
 *  ============================================================================
 */
#define DM64LCPCI_INTSTATUS_MASK      0x00080000

/** ============================================================================
 *  @const   DM64LCPCI_PCIADLEN
 *
 *  @desc    Length each segment of addressable PCI Space..
 *  ============================================================================
 */
#define DM64LCPCI_PCIADLEN            0x00800000

/** ============================================================================
 *  @const   DM64LCPCI_PCIADWRBITMASK
 *
 *  @desc    Mask indicating writeable bits in PCI Address Window registers.
 *  ============================================================================
 */
#define DM64LCPCI_PCIADWRBITMASK      0xFF800000

/** ============================================================================
 *  @const   DM64LCPCI_PAGEWRBITMASK
 *
 *  @desc    Mask indicating writeable bits in PCI Base Address Mask Register5.
 *  ============================================================================
 */
#define DM64LCPCI_PAGEWRBITMASK       0xFF800000

/** ============================================================================
 *  @name   DM64LCPCI_pllRegs
 *
 *  @desc   Register Overlay Structure for Device config registers.
 *  ============================================================================
 */
typedef struct DM64LCPCI_devRegs_tag {
    volatile Uint32 PINMUX0       ;
    volatile Uint32 PINMUX1       ;
    volatile Uint32 DSPBOOTADDR   ;
    volatile Uint32 BOOTCMPLT     ;
    volatile Uint32 RSVD0         ;
    volatile Uint32 BOOTCFG       ;
    volatile Uint32 VDD1P0V_ADJ   ;
    volatile Uint32 VDD1P2V_ADJ   ;
    volatile Uint32 DDR_SLEW      ;
    volatile Uint32 PERIPHEN      ;
    volatile Uint32 DEVICE_ID     ;
    volatile Uint32 DAC_DEMEN     ;
    volatile Uint32 UHPICTL       ;
    volatile Uint32 RSVD1 [2]     ;
    volatile Uint32 MSTPRI0       ;
    volatile Uint32 MSTPRI1       ;
    volatile Uint32 VPSS_CLK_CTRL ;
    volatile Uint32 VDD3P3V_PWRDN ;
    volatile Uint32 DFT_ENABLE    ;
    volatile Uint32 SEC_SCAN_REG  ;
    volatile Uint32 SEC_TEST_REG  ;
    volatile Uint32 SEC_TAP_CTL   ;
    volatile Uint32 PUBLIC_KEY0   ;
    volatile Uint32 PUBLIC_KEY1   ;
    volatile Uint32 PUBLIC_KEY2   ;
    volatile Uint32 PUBLIC_KEY3   ;
    volatile Uint32 VLYNQ_DELAY   ;
    volatile Uint32 SEC_PSEUDO0   ;
    volatile Uint32 SEC_PSEUDO1   ;
    volatile Uint32 RSVD2 [3]     ;
    volatile Uint32 TIMERCTL      ;
    volatile Uint32 TPTCCCFG      ;
    volatile Uint32 RSVD3         ;
} DM64LCPCI_devRegs ;

/** ============================================================================
 *  @name   DM64LCPCI_pllRegs
 *
 *  @desc   Register Overlay Structure for PLL.
 *  ============================================================================
 */
typedef struct DM64LCPCI_pllRegs_tag {
    volatile Uint32 PID         ;
    volatile Uint8  RSVD0 [220] ;
    volatile Uint32 FUSERR      ;
    volatile Uint32 RSTYPE      ;
    volatile Uint32 RSTDEF      ;
    volatile Uint8  RSVD1 [20]  ;
    volatile Uint32 PLLCTL      ;
    volatile Uint32 OCSEL       ;
    volatile Uint32 SECCTL      ;
    volatile Uint8  RSVD2 [4]   ;
    volatile Uint32 PLLM        ;
    volatile Uint32 PREDIV      ;
    volatile Uint32 PLLDIV1     ;
    volatile Uint32 PLLDIV2     ;
    volatile Uint32 PLLDIV3     ;
    volatile Uint32 OSCDIV1     ;
    volatile Uint32 POSTDIV     ;
    volatile Uint32 BPDIV       ;
    volatile Uint32 WAKEUP      ;
    volatile Uint8  RSVD3 [4]   ;
    volatile Uint32 PLLCMD      ;
    volatile Uint32 PLLSTAT     ;
    volatile Uint32 ALNCTL      ;
    volatile Uint32 DCHANGE     ;
    volatile Uint32 CKEN        ;
    volatile Uint32 CKSTAT      ;
    volatile Uint32 SYSTAT      ;
    volatile Uint8  RSVD4 [12]  ;
    volatile Uint32 PLLDIV4     ;
    volatile Uint32 PLLDIV5     ;
    volatile Uint32 PLLDIV6     ;
    volatile Uint32 PLLDIV7     ;
    volatile Uint32 PLLDIV8     ;
} DM64LCPCI_pllRegs ;

/** ============================================================================
 *  @name   DM64LCPCI_ddrRegs
 *
 *  @desc   Register Overlay Structure for DDR.
 *  ============================================================================
 */
typedef struct  {
    volatile Uint32 ERCSR       ;
    volatile Uint32 SDRSTAT     ;
    volatile Uint32 SDBCR       ;
    volatile Uint32 SDRCR       ;
    volatile Uint32 SDTIMR      ;
    volatile Uint32 SDTIMR2     ;
    volatile Uint8  RSVD0 [8]   ;
    volatile Uint32 VBPR        ;
    volatile Uint8  RSVD1 [4]   ;
    volatile Uint32 VBCFG1      ;
    volatile Uint32 VBCFG2      ;
    volatile Uint8  RSVD2 [16]  ;
    volatile Uint32 PERFC1R     ;
    volatile Uint32 PERFC2R     ;
    volatile Uint32 PCCR        ;
    volatile Uint32 PCMRSR      ;
    volatile Uint8  RSVD3 [48]  ;
    volatile Uint32 ASYNCCS2CR  ;
    volatile Uint32 ASYNCCS3CR  ;
    volatile Uint32 ASYNCCS4CR  ;
    volatile Uint32 ASYNCCS5CR  ;
    volatile Uint8  RSVD4 [16]  ;
    volatile Uint32 AWCCR       ;
    volatile Uint8  RSVD5 [28]  ;
    volatile Uint32 IRR         ;
    volatile Uint32 IMR         ;
    volatile Uint32 IMSR        ;
    volatile Uint32 IMCR        ;
    volatile Uint8  RSVD6 [16]  ;
    volatile Uint32 DDRPHYREV   ;
    volatile Uint32 DDRPHYCR    ;
    volatile Uint32 DDRPHYSR    ;
    volatile Uint8  RSVD7 [4]   ;
    volatile Uint32 VTPCTRL     ;
    volatile Uint32 VTPSTAT     ;
} DM64LCPCI_ddrRegs ;

/** ============================================================================
 *  @name   DM64LCPCI_pscRegs
 *
 *  @desc   Register Overlay Structure for PSC.
 *  ============================================================================
 */
typedef struct DM64LCPCI_pscRegs_tag {
    volatile Uint32 PID          ;
    volatile Uint8  RSVD0 [12]   ;
    volatile Uint32 GBLCTL       ;
    volatile Uint8  RSVD1 [4]    ;
    volatile Uint32 INTEVAL      ;
    volatile Uint8  RSVD2 [36]   ;
    volatile Uint32 ERRPR0       ;
    volatile Uint32 ERRPR1       ;
    volatile Uint8  RSVD3 [8]    ;
    volatile Uint32 ERRCR0       ;
    volatile Uint32 ERRCR1       ;
    volatile Uint8  RSVD4 [8]    ;
    volatile Uint32 PERRPR       ;
    volatile Uint8  RSVD5 [4]    ;
    volatile Uint32 PERRCR       ;
    volatile Uint8  RSVD6 [4]    ;
    volatile Uint32 EPCPR        ;
    volatile Uint8  RSVD7 [4]    ;
    volatile Uint32 EPCR         ;
    volatile Uint8  RSVD8 [132]  ;
    volatile Uint32 RAILSTAT     ;
    volatile Uint32 RAILCTL      ;
    volatile Uint32 RAILSEL      ;
    volatile Uint8  RSVD9 [20]   ;
    volatile Uint32 PTCMD        ;
    volatile Uint8  RSVD10 [4]   ;
    volatile Uint32 PTSTAT       ;
    volatile Uint8  RSVD11 [212] ;
    volatile Uint32 PDSTAT [41]  ;
    volatile Uint8  RSVD12 [92]  ;
    volatile Uint32 PDCTL [41]   ;
    volatile Uint8  RSVD13 [348] ;
    volatile Uint32 MRSTOUT [2]  ;
    volatile Uint8  RSVD14 [8]   ;
    volatile Uint32 MCKOUT [2]   ;
    volatile Uint8  RSVD15 [232] ;
    volatile Uint32 MDCFG [41]   ;
    volatile Uint8  RSVD16 [348] ;
    volatile Uint32 MDSTAT [41]  ;
    volatile Uint8  RSVD17 [348] ;
    volatile Uint32 MDCTL [41]   ;
} DM64LCPCI_pscRegs ;

/** ============================================================================
 *  @name   DM64LCPCI_paramEntry
 *

⌨️ 快捷键说明

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