📄 via-velocity.h
字号:
#define PWCFG_PMCSR_PME_EN 0x04 /* control by PCISTICK */#define PWCFG_LEGACY_WOLSR 0x02 /* Legacy WOL_SR shadow */#define PWCFG_LEGACY_WOLEN 0x01 /* Legacy WOL_EN shadow *//* * Bits in WOLCFG */#define WOLCFG_PMEOVR 0x80 /* for legacy use, force PMEEN always */#define WOLCFG_SAM 0x20 /* accept multicast case reset, default=0 */#define WOLCFG_SAB 0x10 /* accept broadcast case reset, default=0 */#define WOLCFG_SMIIACC 0x08 /* ?? */#define WOLCFG_SGENWH 0x02#define WOLCFG_PHYINTEN 0x01 /* 0:PHYINT trigger enable, 1:use internal MII to report status change *//* * Bits in WOLSR1 */#define WOLSR_LINKOFF_INT 0x0800#define WOLSR_LINKON_INT 0x0400#define WOLSR_MAGIC_INT 0x0200#define WOLSR_UNICAST_INT 0x0100/* * Ethernet address filter type */#define PKT_TYPE_NONE 0x0000 /* Turn off receiver */#define PKT_TYPE_DIRECTED 0x0001 /* obselete, directed address is always accepted */#define PKT_TYPE_MULTICAST 0x0002#define PKT_TYPE_ALL_MULTICAST 0x0004#define PKT_TYPE_BROADCAST 0x0008#define PKT_TYPE_PROMISCUOUS 0x0020#define PKT_TYPE_LONG 0x2000 /* NOTE.... the definition of LONG is >2048 bytes in our chip */#define PKT_TYPE_RUNT 0x4000#define PKT_TYPE_ERROR 0x8000 /* Accept error packets, e.g. CRC error *//* * Loopback mode */#define MAC_LB_NONE 0x00#define MAC_LB_INTERNAL 0x01#define MAC_LB_EXTERNAL 0x02/* * Enabled mask value of irq */#if defined(_SIM)#define IMR_MASK_VALUE 0x0033FF0FUL /* initial value of IMR set IMR0 to 0x0F according to spec */#else#define IMR_MASK_VALUE 0x0013FB0FUL /* initial value of IMR ignore MIBFI,RACEI to reduce intr. frequency NOTE.... do not enable NoBuf int mask at driver driver when (1) NoBuf -> RxThreshold = SF (2) OK -> RxThreshold = original value */#endif/* * Revision id */#define REV_ID_VT3119_A0 0x00#define REV_ID_VT3119_A1 0x01#define REV_ID_VT3216_A0 0x10/* * Max time out delay time */#define W_MAX_TIMEOUT 0x0FFFU/* * MAC registers as a structure. Cannot be directly accessed this * way but generates offsets for readl/writel() calls */struct mac_regs { volatile u8 PAR[6]; /* 0x00 */ volatile u8 RCR; volatile u8 TCR; volatile u32 CR0Set; /* 0x08 */ volatile u32 CR0Clr; /* 0x0C */ volatile u8 MARCAM[8]; /* 0x10 */ volatile u32 DecBaseHi; /* 0x18 */ volatile u16 DbfBaseHi; /* 0x1C */ volatile u16 reserved_1E; volatile u16 ISRCTL; /* 0x20 */ volatile u8 TXESR; volatile u8 RXESR; volatile u32 ISR; /* 0x24 */ volatile u32 IMR; volatile u32 TDStatusPort; /* 0x2C */ volatile u16 TDCSRSet; /* 0x30 */ volatile u8 RDCSRSet; volatile u8 reserved_33; volatile u16 TDCSRClr; volatile u8 RDCSRClr; volatile u8 reserved_37; volatile u32 RDBaseLo; /* 0x38 */ volatile u16 RDIdx; /* 0x3C */ volatile u16 reserved_3E; volatile u32 TDBaseLo[4]; /* 0x40 */ volatile u16 RDCSize; /* 0x50 */ volatile u16 TDCSize; /* 0x52 */ volatile u16 TDIdx[4]; /* 0x54 */ volatile u16 tx_pause_timer; /* 0x5C */ volatile u16 RBRDU; /* 0x5E */ volatile u32 FIFOTest0; /* 0x60 */ volatile u32 FIFOTest1; /* 0x64 */ volatile u8 CAMADDR; /* 0x68 */ volatile u8 CAMCR; /* 0x69 */ volatile u8 GFTEST; /* 0x6A */ volatile u8 FTSTCMD; /* 0x6B */ volatile u8 MIICFG; /* 0x6C */ volatile u8 MIISR; volatile u8 PHYSR0; volatile u8 PHYSR1; volatile u8 MIICR; volatile u8 MIIADR; volatile u16 MIIDATA; volatile u16 SoftTimer0; /* 0x74 */ volatile u16 SoftTimer1; volatile u8 CFGA; /* 0x78 */ volatile u8 CFGB; volatile u8 CFGC; volatile u8 CFGD; volatile u16 DCFG; /* 0x7C */ volatile u16 MCFG; volatile u8 TBIST; /* 0x80 */ volatile u8 RBIST; volatile u8 PMCPORT; volatile u8 STICKHW; volatile u8 MIBCR; /* 0x84 */ volatile u8 reserved_85; volatile u8 rev_id; volatile u8 PORSTS; volatile u32 MIBData; /* 0x88 */ volatile u16 EEWrData; volatile u8 reserved_8E; volatile u8 BPMDWr; volatile u8 BPCMD; volatile u8 BPMDRd; volatile u8 EECHKSUM; /* 0x92 */ volatile u8 EECSR; volatile u16 EERdData; /* 0x94 */ volatile u8 EADDR; volatile u8 EMBCMD; volatile u8 JMPSR0; /* 0x98 */ volatile u8 JMPSR1; volatile u8 JMPSR2; volatile u8 JMPSR3; volatile u8 CHIPGSR; /* 0x9C */ volatile u8 TESTCFG; volatile u8 DEBUG; volatile u8 CHIPGCR; volatile u16 WOLCRSet; /* 0xA0 */ volatile u8 PWCFGSet; volatile u8 WOLCFGSet; volatile u16 WOLCRClr; /* 0xA4 */ volatile u8 PWCFGCLR; volatile u8 WOLCFGClr; volatile u16 WOLSRSet; /* 0xA8 */ volatile u16 reserved_AA; volatile u16 WOLSRClr; /* 0xAC */ volatile u16 reserved_AE; volatile u16 PatternCRC[8]; /* 0xB0 */ volatile u32 ByteMask[4][4]; /* 0xC0 */} __attribute__ ((__packed__));enum hw_mib { HW_MIB_ifRxAllPkts = 0, HW_MIB_ifRxOkPkts, HW_MIB_ifTxOkPkts, HW_MIB_ifRxErrorPkts, HW_MIB_ifRxRuntOkPkt, HW_MIB_ifRxRuntErrPkt, HW_MIB_ifRx64Pkts, HW_MIB_ifTx64Pkts, HW_MIB_ifRx65To127Pkts, HW_MIB_ifTx65To127Pkts, HW_MIB_ifRx128To255Pkts, HW_MIB_ifTx128To255Pkts, HW_MIB_ifRx256To511Pkts, HW_MIB_ifTx256To511Pkts, HW_MIB_ifRx512To1023Pkts, HW_MIB_ifTx512To1023Pkts, HW_MIB_ifRx1024To1518Pkts, HW_MIB_ifTx1024To1518Pkts, HW_MIB_ifTxEtherCollisions, HW_MIB_ifRxPktCRCE, HW_MIB_ifRxJumboPkts, HW_MIB_ifTxJumboPkts, HW_MIB_ifRxMacControlFrames, HW_MIB_ifTxMacControlFrames, HW_MIB_ifRxPktFAE, HW_MIB_ifRxLongOkPkt, HW_MIB_ifRxLongPktErrPkt, HW_MIB_ifTXSQEErrors, HW_MIB_ifRxNobuf, HW_MIB_ifRxSymbolErrors, HW_MIB_ifInRangeLengthErrors, HW_MIB_ifLateCollisions, HW_MIB_SIZE};enum chip_type { CHIP_TYPE_VT6110 = 1,};struct velocity_info_tbl { enum chip_type chip_id; char *name; int io_size; int txqueue; u32 flags;};#define mac_hw_mibs_init(regs) {\ BYTE_REG_BITS_ON(MIBCR_MIBFRZ,&((regs)->MIBCR));\ BYTE_REG_BITS_ON(MIBCR_MIBCLR,&((regs)->MIBCR));\ do {}\ while (BYTE_REG_BITS_IS_ON(MIBCR_MIBCLR,&((regs)->MIBCR)));\ BYTE_REG_BITS_OFF(MIBCR_MIBFRZ,&((regs)->MIBCR));\}#define mac_read_isr(regs) readl(&((regs)->ISR))#define mac_write_isr(regs, x) writel((x),&((regs)->ISR))#define mac_clear_isr(regs) writel(0xffffffffL,&((regs)->ISR))#define mac_write_int_mask(mask, regs) writel((mask),&((regs)->IMR));#define mac_disable_int(regs) writel(CR0_GINTMSK1,&((regs)->CR0Clr))#define mac_enable_int(regs) writel(CR0_GINTMSK1,&((regs)->CR0Set))#define mac_hw_mibs_read(regs, MIBs) {\ int i;\ BYTE_REG_BITS_ON(MIBCR_MPTRINI,&((regs)->MIBCR));\ for (i=0;i<HW_MIB_SIZE;i++) {\ (MIBs)[i]=readl(&((regs)->MIBData));\ }\}#define mac_set_dma_length(regs, n) {\ BYTE_REG_BITS_SET((n),0x07,&((regs)->DCFG));\}#define mac_set_rx_thresh(regs, n) {\ BYTE_REG_BITS_SET((n),(MCFG_RFT0|MCFG_RFT1),&((regs)->MCFG));\}#define mac_rx_queue_run(regs) {\ writeb(TRDCSR_RUN, &((regs)->RDCSRSet));\}#define mac_rx_queue_wake(regs) {\ writeb(TRDCSR_WAK, &((regs)->RDCSRSet));\}#define mac_tx_queue_run(regs, n) {\ writew(TRDCSR_RUN<<((n)*4),&((regs)->TDCSRSet));\}#define mac_tx_queue_wake(regs, n) {\ writew(TRDCSR_WAK<<(n*4),&((regs)->TDCSRSet));\}#define mac_eeprom_reload(regs) {\ int i=0;\ BYTE_REG_BITS_ON(EECSR_RELOAD,&((regs)->EECSR));\ do {\ udelay(10);\ if (i++>0x1000) {\ break;\ }\ }while (BYTE_REG_BITS_IS_ON(EECSR_RELOAD,&((regs)->EECSR)));\}enum velocity_cam_type { VELOCITY_VLAN_ID_CAM = 0, VELOCITY_MULTICAST_CAM};/** * mac_get_cam_mask - Read a CAM mask * @regs: register block for this velocity * @mask: buffer to store mask * @cam_type: CAM to fetch * * Fetch the mask bits of the selected CAM and store them into the * provided mask buffer. */static inline void mac_get_cam_mask(struct mac_regs * regs, u8 * mask, enum velocity_cam_type cam_type){ int i; /* Select CAM mask */ BYTE_REG_BITS_SET(CAMCR_PS_CAM_MASK, CAMCR_PS1 | CAMCR_PS0, ®s->CAMCR); if (cam_type == VELOCITY_VLAN_ID_CAM) writeb(CAMADDR_VCAMSL, ®s->CAMADDR); else writeb(0, ®s->CAMADDR); /* read mask */ for (i = 0; i < 8; i++) *mask++ = readb(&(regs->MARCAM[i])); /* disable CAMEN */ writeb(0, ®s->CAMADDR); /* Select mar */ BYTE_REG_BITS_SET(CAMCR_PS_MAR, CAMCR_PS1 | CAMCR_PS0, ®s->CAMCR);}/** * mac_set_cam_mask - Set a CAM mask * @regs: register block for this velocity * @mask: CAM mask to load * @cam_type: CAM to store * * Store a new mask into a CAM */static inline void mac_set_cam_mask(struct mac_regs * regs, u8 * mask, enum velocity_cam_type cam_type){ int i; /* Select CAM mask */ BYTE_REG_BITS_SET(CAMCR_PS_CAM_MASK, CAMCR_PS1 | CAMCR_PS0, ®s->CAMCR); if (cam_type == VELOCITY_VLAN_ID_CAM) writeb(CAMADDR_CAMEN | CAMADDR_VCAMSL, ®s->CAMADDR); else writeb(CAMADDR_CAMEN, ®s->CAMADDR); for (i = 0; i < 8; i++) { writeb(*mask++, &(regs->MARCAM[i])); } /* disable CAMEN */ writeb(0, ®s->CAMADDR); /* Select mar */ BYTE_REG_BITS_SET(CAMCR_PS_MAR, CAMCR_PS1 | CAMCR_PS0, ®s->CAMCR);}/** * mac_set_cam - set CAM data * @regs: register block of this velocity * @idx: Cam index * @addr: 2 or 6 bytes of CAM data * @cam_type: CAM to load * * Load an address or vlan tag into a CAM */static inline void mac_set_cam(struct mac_regs * regs, int idx, u8 *addr, enum velocity_cam_type cam_type){ int i; /* Select CAM mask */ BYTE_REG_BITS_SET(CAMCR_PS_CAM_DATA, CAMCR_PS1 | CAMCR_PS0, ®s->CAMCR); idx &= (64 - 1); if (cam_type == VELOCITY_VLAN_ID_CAM) writeb(CAMADDR_CAMEN | CAMADDR_VCAMSL | idx, ®s->CAMADDR); else writeb(CAMADDR_CAMEN | idx, ®s->CAMADDR); if (cam_type == VELOCITY_VLAN_ID_CAM) writew(*((u16 *) addr), ®s->MARCAM[0]); else { for (i = 0; i < 6; i++) { writeb(*addr++, &(regs->MARCAM[i])); } } BYTE_REG_BITS_ON(CAMCR_CAMWR, ®s->CAMCR); udelay(10); writeb(0, ®s->CAMADDR); /* Select mar */ BYTE_REG_BITS_SET(CAMCR_PS_MAR, CAMCR_PS1 | CAMCR_PS0, ®s->CAMCR);}/** * mac_get_cam - fetch CAM data * @regs: register block of this velocity * @idx: Cam index * @addr: buffer to hold up to 6 bytes of CAM data * @cam_type: CAM to load * * Load an address or vlan tag from a CAM into the buffer provided by * the caller. VLAN tags are 2 bytes the address cam entries are 6. */static inline void mac_get_cam(struct mac_regs * regs, int idx, u8 *addr, enum velocity_cam_type cam_type){ int i; /* Select CAM mask */ BYTE_REG_BITS_SET(CAMCR_PS_CAM_DATA, CAMCR_PS1 | CAMCR_PS0, ®s->CAMCR); idx &= (64 - 1); if (cam_type == VELOCITY_VLAN_ID_CAM) writeb(CAMADDR_CAMEN | CAMADDR_VCAMSL | idx, ®s->CAMADDR); else writeb(CAMADDR_CAMEN | idx, ®s->CAMADDR); BYTE_REG_BITS_ON(CAMCR_CAMRD, ®s->CAMCR); udelay(10); if (cam_type == VELOCITY_VLAN_ID_CAM) *((u16 *) addr) = readw(&(regs->MARCAM[0])); else for (i = 0; i < 6; i++, addr++) *((u8 *) addr) = readb(&(regs->MARCAM[i])); writeb(0, ®s->CAMADDR); /* Select mar */ BYTE_REG_BITS_SET(CAMCR_PS_MAR, CAMCR_PS1 | CAMCR_PS0, ®s->CAMCR);}/** * mac_wol_reset - reset WOL after exiting low power * @regs: register block of this velocity * * Called after we drop out of wake on lan mode in order to * reset the Wake on lan features. This function doesn't restore
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -