natsemi.h

Go to the documentation of this file.
00001 FILE_LICENCE ( GPL_ANY );
00002 
00003 #define NATSEMI_HW_TIMEOUT 400
00004 
00005 #define TX_RING_SIZE 4
00006 #define NUM_RX_DESC  4
00007 #define RX_BUF_SIZE 1536
00008 #define OWN       0x80000000
00009 #define DSIZE     0x00000FFF
00010 #define CRC_SIZE  4
00011 
00012 struct natsemi_tx {
00013         uint32_t link;
00014         uint32_t cmdsts;
00015         uint32_t bufptr;
00016 };
00017 
00018 struct natsemi_rx {
00019         uint32_t link;
00020         uint32_t cmdsts;
00021         uint32_t bufptr;
00022 };
00023 
00024 struct natsemi_private {
00025         unsigned short ioaddr;
00026         unsigned short tx_cur;
00027         unsigned short tx_dirty;
00028         unsigned short rx_cur;
00029         struct natsemi_tx tx[TX_RING_SIZE];
00030         struct natsemi_rx rx[NUM_RX_DESC];
00031 
00032         /* need to add iobuf as we cannot free iobuf->data in close without this 
00033          * alternatively substracting sizeof(head) and sizeof(list_head) can also 
00034          * give the same.
00035          */
00036         struct io_buffer *iobuf[NUM_RX_DESC];
00037 
00038         /* netdev_tx_complete needs pointer to the iobuf of the data so as to free 
00039          * it from the memory.
00040          */
00041         struct io_buffer *tx_iobuf[TX_RING_SIZE];
00042         struct spi_bit_basher spibit;
00043         struct spi_device eeprom;
00044         struct nvo_block nvo;
00045 };
00046 
00047 /*
00048  * Support for fibre connections on Am79C874:
00049  * This phy needs a special setup when connected to a fibre cable.
00050  * http://www.amd.com/files/connectivitysolutions/networking/archivednetworking/22235.pdf
00051  */
00052 #define PHYID_AM79C874  0x0022561b
00053 
00054 enum {
00055         MII_MCTRL       = 0x15,         /* mode control register */
00056         MII_FX_SEL      = 0x0001,       /* 100BASE-FX (fiber) */
00057         MII_EN_SCRM     = 0x0004,       /* enable scrambler (tp) */
00058 };
00059 
00060 
00061 
00062 /* values we might find in the silicon revision register */
00063 #define SRR_DP83815_C   0x0302
00064 #define SRR_DP83815_D   0x0403
00065 #define SRR_DP83816_A4  0x0504
00066 #define SRR_DP83816_A5  0x0505
00067 
00068 /* NATSEMI: Offsets to the device registers.
00069  * Unlike software-only systems, device drivers interact with complex hardware.
00070  * It's not useful to define symbolic names for every register bit in the
00071  * device.
00072  */
00073 enum register_offsets {
00074     ChipCmd      = 0x00, 
00075     ChipConfig   = 0x04, 
00076     EECtrl       = 0x08, 
00077     PCIBusCfg    = 0x0C,
00078     IntrStatus   = 0x10, 
00079     IntrMask     = 0x14, 
00080     IntrEnable   = 0x18,
00081     TxRingPtr    = 0x20, 
00082     TxConfig     = 0x24,
00083     RxRingPtr    = 0x30,
00084     RxConfig     = 0x34, 
00085     ClkRun       = 0x3C,
00086     WOLCmd       = 0x40, 
00087     PauseCmd     = 0x44,
00088     RxFilterAddr = 0x48, 
00089     RxFilterData = 0x4C,
00090     BootRomAddr  = 0x50, 
00091     BootRomData  = 0x54, 
00092     SiliconRev   = 0x58, 
00093     StatsCtrl    = 0x5C,
00094     StatsData    = 0x60, 
00095     RxPktErrs    = 0x60, 
00096     RxMissed     = 0x68, 
00097     RxCRCErrs    = 0x64,
00098     PCIPM        = 0x44,
00099     PhyStatus    = 0xC0, 
00100     MIntrCtrl    = 0xC4, 
00101     MIntrStatus  = 0xC8,
00102 
00103     /* These are from the spec, around page 78... on a separate table. 
00104      */
00105     PGSEL        = 0xCC, 
00106     PMDCSR       = 0xE4, 
00107     TSTDAT       = 0xFC, 
00108     DSPCFG       = 0xF4, 
00109     SDCFG        = 0x8C,
00110     BasicControl = 0x80,        
00111     BasicStatus  = 0x84
00112             
00113 };
00114 
00115 /* the values for the 'magic' registers above (PGSEL=1) */
00116 #define PMDCSR_VAL      0x189c  /* enable preferred adaptation circuitry */
00117 #define TSTDAT_VAL      0x0
00118 #define DSPCFG_VAL      0x5040
00119 #define SDCFG_VAL       0x008c  /* set voltage thresholds for Signal Detect */
00120 #define DSPCFG_LOCK     0x20    /* coefficient lock bit in DSPCFG */
00121 #define DSPCFG_COEF     0x1000  /* see coefficient (in TSTDAT) bit in DSPCFG */
00122 #define TSTDAT_FIXED    0xe8    /* magic number for bad coefficients */
00123 
00124 /* Bit in ChipCmd.
00125  */
00126 enum ChipCmdBits {
00127     ChipReset = 0x100, 
00128     RxReset   = 0x20, 
00129     TxReset   = 0x10, 
00130     RxOff     = 0x08, 
00131     RxOn      = 0x04,
00132     TxOff     = 0x02, 
00133     TxOn      = 0x01
00134 };
00135 
00136 enum ChipConfig_bits {
00137         CfgPhyDis               = 0x200,
00138         CfgPhyRst               = 0x400,
00139         CfgExtPhy               = 0x1000,
00140         CfgAnegEnable           = 0x2000,
00141         CfgAneg100              = 0x4000,
00142         CfgAnegFull             = 0x8000,
00143         CfgAnegDone             = 0x8000000,
00144         CfgFullDuplex           = 0x20000000,
00145         CfgSpeed100             = 0x40000000,
00146         CfgLink                 = 0x80000000,
00147 };
00148 
00149 
00150 /* Bits in the RxMode register.
00151  */
00152 enum rx_mode_bits {
00153     AcceptErr          = 0x20,
00154     AcceptRunt         = 0x10,
00155     AcceptBroadcast    = 0xC0000000,
00156     AcceptMulticast    = 0x00200000, 
00157     AcceptAllMulticast = 0x20000000,
00158     AcceptAllPhys      = 0x10000000, 
00159     AcceptMyPhys       = 0x08000000,
00160     RxFilterEnable     = 0x80000000
00161 };
00162 
00163 /* Bits in network_desc.status
00164  */
00165 enum desc_status_bits {
00166     DescOwn   = 0x80000000, 
00167     DescMore  = 0x40000000, 
00168     DescIntr  = 0x20000000,
00169     DescNoCRC = 0x10000000,
00170     DescPktOK = 0x08000000, 
00171     RxTooLong = 0x00400000
00172 };
00173 
00174 /*Bits in Interrupt Mask register
00175  */
00176 enum Intr_mask_register_bits {
00177     RxOk       = 0x001,
00178     RxErr      = 0x004,
00179     TxOk       = 0x040,
00180     TxErr      = 0x100 
00181 };      
00182 
00183 enum MIntrCtrl_bits {
00184   MICRIntEn               = 0x2,
00185 };
00186 
00187 /* CFG bits [13:16] [18:23] */
00188 #define CFG_RESET_SAVE 0xfde000
00189 /* WCSR bits [0:4] [9:10] */
00190 #define WCSR_RESET_SAVE 0x61f
00191 /* RFCR bits [20] [22] [27:31] */
00192 #define RFCR_RESET_SAVE 0xf8500000;
00193 
00194 /* Delay between EEPROM clock transitions.
00195    No extra delay is needed with 33Mhz PCI, but future 66Mhz access may need
00196    a delay. */
00197 #define eeprom_delay(ee_addr)   inl(ee_addr)
00198 
00199 enum EEPROM_Ctrl_Bits {
00200         EE_ShiftClk   = 0x04,
00201         EE_DataIn     = 0x01,
00202         EE_ChipSelect = 0x08,
00203         EE_DataOut    = 0x02
00204 };
00205 
00206 #define EE_Write0 (EE_ChipSelect)
00207 #define EE_Write1 (EE_ChipSelect | EE_DataIn)
00208 
00209 /* The EEPROM commands include the alway-set leading bit. */
00210 enum EEPROM_Cmds {
00211   EE_WriteCmd=(5 << 6), EE_ReadCmd=(6 << 6), EE_EraseCmd=(7 << 6),
00212 };
00213 
00214 /*  EEPROM access , values are devices specific
00215  */
00216 #define EE_CS           0x08    /* EEPROM chip select */
00217 #define EE_SK           0x04    /* EEPROM shift clock */
00218 #define EE_DI           0x01    /* Data in */
00219 #define EE_DO           0x02    /* Data out */
00220 
00221 /* Offsets within EEPROM (these are word offsets)
00222  */
00223 #define EE_MAC 7
00224 #define EE_REG  EECtrl
00225 
00226 static const uint8_t natsemi_ee_bits[] = {
00227         [SPI_BIT_SCLK]  = EE_SK,
00228         [SPI_BIT_MOSI]  = EE_DI,
00229         [SPI_BIT_MISO]  = EE_DO,
00230         [SPI_BIT_SS(0)] = EE_CS,
00231 };
00232 

Generated on Tue Apr 6 20:01:01 2010 for gPXE by  doxygen 1.5.7.1