b44.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 FILE_LICENCE ( GPL2_OR_LATER );
00032
00033 #ifndef _B44_H
00034 #define _B44_H
00035
00036
00037 #define B44_DEVCTRL 0x0000UL
00038 #define DEVCTRL_MPM 0x00000040
00039 #define DEVCTRL_PFE 0x00000080
00040 #define DEVCTRL_IPP 0x00000400
00041 #define DEVCTRL_EPR 0x00008000
00042 #define DEVCTRL_PME 0x00001000
00043 #define DEVCTRL_PMCE 0x00002000
00044 #define DEVCTRL_PADDR 0x0007c000
00045 #define DEVCTRL_PADDR_SHIFT 18
00046 #define B44_BIST_STAT 0x000CUL
00047 #define B44_WKUP_LEN 0x0010UL
00048 #define WKUP_LEN_P0_MASK 0x0000007f
00049 #define WKUP_LEN_D0 0x00000080
00050 #define WKUP_LEN_P1_MASK 0x00007f00
00051 #define WKUP_LEN_P1_SHIFT 8
00052 #define WKUP_LEN_D1 0x00008000
00053 #define WKUP_LEN_P2_MASK 0x007f0000
00054 #define WKUP_LEN_P2_SHIFT 16
00055 #define WKUP_LEN_D2 0x00000000
00056 #define WKUP_LEN_P3_MASK 0x7f000000
00057 #define WKUP_LEN_P3_SHIFT 24
00058 #define WKUP_LEN_D3 0x80000000
00059 #define WKUP_LEN_DISABLE 0x80808080
00060 #define WKUP_LEN_ENABLE_TWO 0x80800000
00061 #define WKUP_LEN_ENABLE_THREE 0x80000000
00062 #define B44_ISTAT 0x0020UL
00063 #define ISTAT_LS 0x00000020
00064 #define ISTAT_PME 0x00000040
00065 #define ISTAT_TO 0x00000080
00066 #define ISTAT_DSCE 0x00000400
00067 #define ISTAT_DATAE 0x00000800
00068 #define ISTAT_DPE 0x00001000
00069 #define ISTAT_RDU 0x00002000
00070 #define ISTAT_RFO 0x00004000
00071 #define ISTAT_TFU 0x00008000
00072 #define ISTAT_RX 0x00010000
00073 #define ISTAT_TX 0x01000000
00074 #define ISTAT_EMAC 0x04000000
00075 #define ISTAT_MII_WRITE 0x08000000
00076 #define ISTAT_MII_READ 0x10000000
00077 #define ISTAT_ERRORS (ISTAT_DSCE|ISTAT_DATAE|ISTAT_DPE|\
00078 ISTAT_RDU|ISTAT_RFO|ISTAT_TFU)
00079 #define B44_IMASK 0x0024UL
00080 #define IMASK_DEF (ISTAT_ERRORS | ISTAT_RX | ISTAT_TX)
00081 #define IMASK_DISABLE 0
00082 #define B44_GPTIMER 0x0028UL
00083 #define B44_ADDR_LO 0x0088UL
00084 #define B44_ADDR_HI 0x008CUL
00085 #define B44_FILT_ADDR 0x0090UL
00086 #define B44_FILT_DATA 0x0094UL
00087 #define B44_TXBURST 0x00A0UL
00088 #define B44_RXBURST 0x00A4UL
00089 #define B44_MAC_CTRL 0x00A8UL
00090 #define MAC_CTRL_CRC32_ENAB 0x00000001
00091 #define MAC_CTRL_PHY_PDOWN 0x00000004
00092 #define MAC_CTRL_PHY_EDET 0x00000008
00093 #define MAC_CTRL_PHY_LEDCTRL 0x000000e0
00094 #define MAC_CTRL_PHY_LEDCTRL_SHIFT 5
00095 #define B44_MAC_FLOW 0x00ACUL
00096 #define MAC_FLOW_RX_HI_WATER 0x000000ff
00097 #define MAC_FLOW_PAUSE_ENAB 0x00008000
00098 #define B44_RCV_LAZY 0x0100UL
00099 #define RCV_LAZY_TO_MASK 0x00ffffff
00100 #define RCV_LAZY_FC_MASK 0xff000000
00101 #define RCV_LAZY_FC_SHIFT 24
00102 #define B44_DMATX_CTRL 0x0200UL
00103 #define DMATX_CTRL_ENABLE 0x00000001
00104 #define DMATX_CTRL_SUSPEND 0x00000002
00105 #define DMATX_CTRL_LPBACK 0x00000004
00106 #define DMATX_CTRL_FAIRPRIOR 0x00000008
00107 #define DMATX_CTRL_FLUSH 0x00000010
00108 #define B44_DMATX_ADDR 0x0204UL
00109 #define B44_DMATX_PTR 0x0208UL
00110 #define B44_DMATX_STAT 0x020CUL
00111 #define DMATX_STAT_CDMASK 0x00000fff
00112 #define DMATX_STAT_SMASK 0x0000f000
00113 #define DMATX_STAT_SDISABLED 0x00000000
00114 #define DMATX_STAT_SACTIVE 0x00001000
00115 #define DMATX_STAT_SIDLE 0x00002000
00116 #define DMATX_STAT_SSTOPPED 0x00003000
00117 #define DMATX_STAT_SSUSP 0x00004000
00118 #define DMATX_STAT_EMASK 0x000f0000
00119 #define DMATX_STAT_ENONE 0x00000000
00120 #define DMATX_STAT_EDPE 0x00010000
00121 #define DMATX_STAT_EDFU 0x00020000
00122 #define DMATX_STAT_EBEBR 0x00030000
00123 #define DMATX_STAT_EBEDA 0x00040000
00124 #define DMATX_STAT_FLUSHED 0x00100000
00125 #define B44_DMARX_CTRL 0x0210UL
00126 #define DMARX_CTRL_ENABLE 0x00000001
00127 #define DMARX_CTRL_ROMASK 0x000000fe
00128 #define DMARX_CTRL_ROSHIFT 1
00129 #define B44_DMARX_ADDR 0x0214UL
00130 #define B44_DMARX_PTR 0x0218UL
00131 #define B44_DMARX_STAT 0x021CUL
00132 #define DMARX_STAT_CDMASK 0x00000fff
00133 #define DMARX_STAT_SMASK 0x0000f000
00134 #define DMARX_STAT_SDISABLED 0x00000000
00135 #define DMARX_STAT_SACTIVE 0x00001000
00136 #define DMARX_STAT_SIDLE 0x00002000
00137 #define DMARX_STAT_SSTOPPED 0x00003000
00138 #define DMARX_STAT_EMASK 0x000f0000
00139 #define DMARX_STAT_ENONE 0x00000000
00140 #define DMARX_STAT_EDPE 0x00010000
00141 #define DMARX_STAT_EDFO 0x00020000
00142 #define DMARX_STAT_EBEBW 0x00030000
00143 #define DMARX_STAT_EBEDA 0x00040000
00144 #define B44_DMAFIFO_AD 0x0220UL
00145 #define DMAFIFO_AD_OMASK 0x0000ffff
00146 #define DMAFIFO_AD_SMASK 0x000f0000
00147 #define DMAFIFO_AD_SXDD 0x00000000
00148 #define DMAFIFO_AD_SXDP 0x00010000
00149 #define DMAFIFO_AD_SRDD 0x00040000
00150 #define DMAFIFO_AD_SRDP 0x00050000
00151 #define DMAFIFO_AD_SXFD 0x00080000
00152 #define DMAFIFO_AD_SXFP 0x00090000
00153 #define DMAFIFO_AD_SRFD 0x000c0000
00154 #define DMAFIFO_AD_SRFP 0x000c0000
00155 #define B44_DMAFIFO_LO 0x0224UL
00156 #define B44_DMAFIFO_HI 0x0228UL
00157 #define B44_RXCONFIG 0x0400UL
00158 #define RXCONFIG_DBCAST 0x00000001
00159 #define RXCONFIG_ALLMULTI 0x00000002
00160 #define RXCONFIG_NORX_WHILE_TX 0x00000004
00161 #define RXCONFIG_PROMISC 0x00000008
00162 #define RXCONFIG_LPBACK 0x00000010
00163 #define RXCONFIG_FLOW 0x00000020
00164 #define RXCONFIG_FLOW_ACCEPT 0x00000040
00165 #define RXCONFIG_RFILT 0x00000080
00166 #define B44_RXMAXLEN 0x0404UL
00167 #define B44_TXMAXLEN 0x0408UL
00168 #define B44_MDIO_CTRL 0x0410UL
00169 #define MDIO_CTRL_MAXF_MASK 0x0000007f
00170 #define MDIO_CTRL_PREAMBLE 0x00000080
00171 #define B44_MDIO_DATA 0x0414UL
00172 #define MDIO_DATA_DATA 0x0000ffff
00173 #define MDIO_DATA_TA_MASK 0x00030000
00174 #define MDIO_DATA_TA_SHIFT 16
00175 #define MDIO_TA_VALID 2
00176 #define MDIO_DATA_RA_MASK 0x007c0000
00177 #define MDIO_DATA_RA_SHIFT 18
00178 #define MDIO_DATA_PMD_MASK 0x0f800000
00179 #define MDIO_DATA_PMD_SHIFT 23
00180 #define MDIO_DATA_OP_MASK 0x30000000
00181 #define MDIO_DATA_OP_SHIFT 28
00182 #define MDIO_OP_WRITE 1
00183 #define MDIO_OP_READ 2
00184 #define MDIO_DATA_SB_MASK 0xc0000000
00185 #define MDIO_DATA_SB_SHIFT 30
00186 #define MDIO_DATA_SB_START 0x40000000
00187 #define B44_EMAC_IMASK 0x0418UL
00188 #define B44_EMAC_ISTAT 0x041CUL
00189 #define EMAC_INT_MII 0x00000001
00190 #define EMAC_INT_MIB 0x00000002
00191 #define EMAC_INT_FLOW 0x00000003
00192 #define B44_CAM_DATA_LO 0x0420UL
00193 #define B44_CAM_DATA_HI 0x0424UL
00194 #define CAM_DATA_HI_VALID 0x00010000
00195 #define B44_CAM_CTRL 0x0428UL
00196 #define CAM_CTRL_ENABLE 0x00000001
00197 #define CAM_CTRL_MSEL 0x00000002
00198 #define CAM_CTRL_READ 0x00000004
00199 #define CAM_CTRL_WRITE 0x00000008
00200 #define CAM_CTRL_INDEX_MASK 0x003f0000
00201 #define CAM_CTRL_INDEX_SHIFT 16
00202 #define CAM_CTRL_BUSY 0x80000000
00203 #define B44_ENET_CTRL 0x042CUL
00204 #define ENET_CTRL_ENABLE 0x00000001
00205 #define ENET_CTRL_DISABLE 0x00000002
00206 #define ENET_CTRL_SRST 0x00000004
00207 #define ENET_CTRL_EPSEL 0x00000008
00208 #define B44_TX_CTRL 0x0430UL
00209 #define TX_CTRL_DUPLEX 0x00000001
00210 #define TX_CTRL_FMODE 0x00000002
00211 #define TX_CTRL_SBENAB 0x00000004
00212 #define TX_CTRL_SMALL_SLOT 0x00000008
00213 #define B44_TX_HIWMARK 0x0434UL
00214 #define TX_HIWMARK_DEFLT 56
00215 #define B44_MIB_CTRL 0x0438UL
00216 #define MIB_CTRL_CLR_ON_READ 0x00000001
00217 #define B44_TX_GOOD_O 0x0500UL
00218 #define B44_TX_GOOD_P 0x0504UL
00219 #define B44_TX_O 0x0508UL
00220 #define B44_TX_P 0x050CUL
00221 #define B44_TX_BCAST 0x0510UL
00222 #define B44_TX_MCAST 0x0514UL
00223 #define B44_TX_64 0x0518UL
00224 #define B44_TX_65_127 0x051CUL
00225 #define B44_TX_128_255 0x0520UL
00226 #define B44_TX_256_511 0x0524UL
00227 #define B44_TX_512_1023 0x0528UL
00228 #define B44_TX_1024_MAX 0x052CUL
00229 #define B44_TX_JABBER 0x0530UL
00230 #define B44_TX_OSIZE 0x0534UL
00231 #define B44_TX_FRAG 0x0538UL
00232 #define B44_TX_URUNS 0x053CUL
00233 #define B44_TX_TCOLS 0x0540UL
00234 #define B44_TX_SCOLS 0x0544UL
00235 #define B44_TX_MCOLS 0x0548UL
00236 #define B44_TX_ECOLS 0x054CUL
00237 #define B44_TX_LCOLS 0x0550UL
00238 #define B44_TX_DEFERED 0x0554UL
00239 #define B44_TX_CLOST 0x0558UL
00240 #define B44_TX_PAUSE 0x055CUL
00241 #define B44_RX_GOOD_O 0x0580UL
00242 #define B44_RX_GOOD_P 0x0584UL
00243 #define B44_RX_O 0x0588UL
00244 #define B44_RX_P 0x058CUL
00245 #define B44_RX_BCAST 0x0590UL
00246 #define B44_RX_MCAST 0x0594UL
00247 #define B44_RX_64 0x0598UL
00248 #define B44_RX_65_127 0x059CUL
00249 #define B44_RX_128_255 0x05A0UL
00250 #define B44_RX_256_511 0x05A4UL
00251 #define B44_RX_512_1023 0x05A8UL
00252 #define B44_RX_1024_MAX 0x05ACUL
00253 #define B44_RX_JABBER 0x05B0UL
00254 #define B44_RX_OSIZE 0x05B4UL
00255 #define B44_RX_FRAG 0x05B8UL
00256 #define B44_RX_MISS 0x05BCUL
00257 #define B44_RX_CRCA 0x05C0UL
00258 #define B44_RX_USIZE 0x05C4UL
00259 #define B44_RX_CRC 0x05C8UL
00260 #define B44_RX_ALIGN 0x05CCUL
00261 #define B44_RX_SYM 0x05D0UL
00262 #define B44_RX_PAUSE 0x05D4UL
00263 #define B44_RX_NPAUSE 0x05D8UL
00264
00265
00266 #define B44_SBIMSTATE 0x0F90UL
00267 #define SBIMSTATE_PC 0x0000000f
00268 #define SBIMSTATE_AP_MASK 0x00000030
00269 #define SBIMSTATE_AP_BOTH 0x00000000
00270 #define SBIMSTATE_AP_TS 0x00000010
00271 #define SBIMSTATE_AP_TK 0x00000020
00272 #define SBIMSTATE_AP_RSV 0x00000030
00273 #define SBIMSTATE_IBE 0x00020000
00274 #define SBIMSTATE_TO 0x00040000
00275 #define SBIMSTATE_BAD ( SBIMSTATE_IBE | SBIMSTATE_TO )
00276 #define B44_SBINTVEC 0x0F94UL
00277 #define SBINTVEC_PCI 0x00000001
00278 #define SBINTVEC_ENET0 0x00000002
00279 #define SBINTVEC_ILINE20 0x00000004
00280 #define SBINTVEC_CODEC 0x00000008
00281 #define SBINTVEC_USB 0x00000010
00282 #define SBINTVEC_EXTIF 0x00000020
00283 #define SBINTVEC_ENET1 0x00000040
00284 #define B44_SBTMSLOW 0x0F98UL
00285 #define SBTMSLOW_RESET 0x00000001
00286 #define SBTMSLOW_REJECT 0x00000002
00287 #define SBTMSLOW_CLOCK 0x00010000
00288 #define SBTMSLOW_FGC 0x00020000
00289 #define SBTMSLOW_PE 0x40000000
00290 #define SBTMSLOW_BE 0x80000000
00291 #define B44_SBTMSHIGH 0x0F9CUL
00292 #define SBTMSHIGH_SERR 0x00000001
00293 #define SBTMSHIGH_INT 0x00000002
00294 #define SBTMSHIGH_BUSY 0x00000004
00295 #define SBTMSHIGH_GCR 0x20000000
00296 #define SBTMSHIGH_BISTF 0x40000000
00297 #define SBTMSHIGH_BISTD 0x80000000
00298 #define B44_SBIDHIGH 0x0FFCUL
00299 #define SBIDHIGH_RC_MASK 0x0000000f
00300 #define SBIDHIGH_CC_MASK 0x0000fff0
00301 #define SBIDHIGH_CC_SHIFT 4
00302 #define SBIDHIGH_VC_MASK 0xffff0000
00303 #define SBIDHIGH_VC_SHIFT 16
00304
00305
00306 #define SSB_PMCSR 0x44
00307 #define SSB_PE 0x100
00308 #define SSB_BAR0_WIN 0x80
00309 #define SSB_BAR1_WIN 0x84
00310 #define SSB_SPROM_CONTROL 0x88
00311 #define SSB_BAR1_CONTROL 0x8c
00312
00313
00314 #define SSB_CONTROL 0x0000UL
00315 #define SSB_ARBCONTROL 0x0010UL
00316 #define SSB_ISTAT 0x0020UL
00317 #define SSB_IMASK 0x0024UL
00318 #define SSB_MBOX 0x0028UL
00319 #define SSB_BCAST_ADDR 0x0050UL
00320 #define SSB_BCAST_DATA 0x0054UL
00321 #define SSB_PCI_TRANS_0 0x0100UL
00322 #define SSB_PCI_TRANS_1 0x0104UL
00323 #define SSB_PCI_TRANS_2 0x0108UL
00324 #define SSB_SPROM 0x0800UL
00325
00326 #define SSB_PCI_MEM 0x00000000
00327 #define SSB_PCI_IO 0x00000001
00328 #define SSB_PCI_CFG0 0x00000002
00329 #define SSB_PCI_CFG1 0x00000003
00330 #define SSB_PCI_PREF 0x00000004
00331 #define SSB_PCI_BURST 0x00000008
00332 #define SSB_PCI_MASK0 0xfc000000
00333 #define SSB_PCI_MASK1 0xfc000000
00334 #define SSB_PCI_MASK2 0xc0000000
00335
00336
00337 #define B44_MII_AUXCTRL 24
00338 #define MII_AUXCTRL_DUPLEX 0x0001
00339 #define MII_AUXCTRL_SPEED 0x0002
00340 #define MII_AUXCTRL_FORCED 0x0004
00341 #define B44_MII_ALEDCTRL 26
00342 #define MII_ALEDCTRL_ALLMSK 0x7fff
00343 #define B44_MII_TLEDCTRL 27
00344 #define MII_TLEDCTRL_ENABLE 0x0040
00345
00346
00347 struct dma_desc {
00348 u32 ctrl;
00349 u32 addr;
00350 };
00351
00352
00353
00354
00355 #define B44_DMA_ALIGNMENT 4096
00356
00357
00358
00359 #define B44_30BIT_DMA_MASK 0x3fffffff
00360
00361 #define DESC_CTRL_LEN 0x00001fff
00362 #define DESC_CTRL_CMASK 0x0ff00000
00363 #define DESC_CTRL_EOT 0x10000000
00364 #define DESC_CTRL_IOC 0x20000000
00365 #define DESC_CTRL_EOF 0x40000000
00366 #define DESC_CTRL_SOF 0x80000000
00367
00368 struct rx_header {
00369 u16 len;
00370 u16 flags;
00371 u16 pad[12];
00372 };
00373 #define RX_HEADER_LEN 28
00374
00375 #define RX_FLAG_OFIFO 0x00000001
00376 #define RX_FLAG_CRCERR 0x00000002
00377 #define RX_FLAG_SERR 0x00000004
00378 #define RX_FLAG_ODD 0x00000008
00379 #define RX_FLAG_LARGE 0x00000010
00380 #define RX_FLAG_MCAST 0x00000020
00381 #define RX_FLAG_BCAST 0x00000040
00382 #define RX_FLAG_MISS 0x00000080
00383 #define RX_FLAG_LAST 0x00000800
00384 #define RX_FLAG_ERRORS (RX_FLAG_ODD | RX_FLAG_SERR |\
00385 RX_FLAG_CRCERR | RX_FLAG_OFIFO)
00386
00387
00388 #define SB_PCI_DMA 0x40000000
00389
00390
00391 #define BCM4400_PCI_CORE_ADDR 0x18002000
00392
00393
00394 #define B44_MIN_MTU 60
00395 #define B44_MAX_MTU 1500
00396
00397 #define B44_RING_SIZE 8
00398 #define B44_RING_LAST ( B44_RING_SIZE - 1 )
00399
00400 #define B44_RX_RING_LEN_BYTES ( sizeof bp->rx[0] * B44_RING_SIZE )
00401 #define B44_TX_RING_LEN_BYTES ( sizeof bp->tx[0] * B44_RING_SIZE )
00402
00403 #define RX_PKT_OFFSET 30
00404 #define RX_PKT_BUF_SZ (1536 + RX_PKT_OFFSET + 64)
00405
00406 #define B44_FULL_RESET 1
00407 #define B44_FULL_RESET_SKIP_PHY 2
00408 #define B44_PARTIAL_RESET 3
00409 #define B44_CHIP_RESET_FULL 4
00410 #define B44_CHIP_RESET_PARTIAL 5
00411
00412 #define SSB_CORE_DOWN ( SBTMSLOW_RESET | SBTMSLOW_REJECT )
00413
00414 #define B44_REGS_SIZE 8192
00415
00416
00417 struct b44_private {
00418 struct net_device *netdev;
00419 struct pci_device *pci;
00420 u8 *regs;
00421 u8 phy_addr;
00422
00423 struct dma_desc *tx;
00424 struct io_buffer *tx_iobuf[B44_RING_SIZE];
00425 u32 tx_cur;
00426 u32 tx_dirty;
00427
00428 struct dma_desc *rx;
00429 struct io_buffer *rx_iobuf[B44_RING_SIZE];
00430 u32 rx_cur;
00431 };
00432
00433
00434 static void ssb_core_reset ( struct b44_private *bp );
00435 static void ssb_core_disable ( struct b44_private *bp );
00436 static u32 ssb_pci_setup ( struct b44_private *bp, u32 cores );
00437
00438 static void b44_chip_reset ( struct b44_private *bp, int reset_kind );
00439 static void b44_init_hw ( struct b44_private *bp, int reset_kind );
00440 static void b44_cam_write ( struct b44_private *bp, u8 *data, int index );
00441 static void b44_set_mac_addr ( struct b44_private *bp );
00442 static void b44_set_rx_mode ( struct net_device *netdev );
00443 static void b44_halt(struct b44_private *);
00444
00445 static int b44_phy_reset ( struct b44_private *bp );
00446 static int b44_phy_write ( struct b44_private *bp, int reg, u32 val );
00447 static int b44_phy_read ( struct b44_private *bp, int reg, u32 *val );
00448
00449 static int b44_init_tx_ring ( struct b44_private *bp );
00450 static void b44_free_tx_ring ( struct b44_private *bp );
00451 static int b44_init_rx_ring ( struct b44_private *bp );
00452 static void b44_free_rx_ring ( struct b44_private *bp );
00453 static void b44_rx_refill ( struct b44_private *bp, u32 pending );
00454 static void b44_populate_rx_descriptor (struct b44_private *bp, u32 index);
00455
00456 static int b44_probe ( struct pci_device *pci,
00457 const struct pci_device_id *id );
00458 static void b44_remove ( struct pci_device *pci );
00459
00460 static int b44_open ( struct net_device *netdev );
00461 static void b44_close ( struct net_device *netdev );
00462 static void b44_irq ( struct net_device *netdev, int enable );
00463 static void b44_poll ( struct net_device *netdev );
00464 static void b44_process_rx_packets ( struct b44_private *bp );
00465 static int b44_transmit ( struct net_device *netdev,
00466 struct io_buffer *iobuf );
00467
00468 static struct net_device_operations b44_operations;
00469
00470 #endif