Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * drivers/net/ethernet/freescale/fec_mpc52xx.h
0003  *
0004  * Driver for the MPC5200 Fast Ethernet Controller
0005  *
0006  * Author: Dale Farnsworth <dfarnsworth@mvista.com>
0007  *
0008  * 2003-2004 (c) MontaVista, Software, Inc.  This file is licensed under
0009  * the terms of the GNU General Public License version 2.  This program
0010  * is licensed "as is" without any warranty of any kind, whether express
0011  * or implied.
0012  */
0013 
0014 #ifndef __DRIVERS_NET_MPC52XX_FEC_H__
0015 #define __DRIVERS_NET_MPC52XX_FEC_H__
0016 
0017 #include <linux/phy.h>
0018 
0019 /* Tunable constant */
0020 /* FEC_RX_BUFFER_SIZE includes 4 bytes for CRC32 */
0021 #define FEC_RX_BUFFER_SIZE  1522    /* max receive packet size */
0022 #define FEC_RX_NUM_BD       256
0023 #define FEC_TX_NUM_BD       64
0024 
0025 #define FEC_RESET_DELAY     50  /* uS */
0026 
0027 #define FEC_WATCHDOG_TIMEOUT    ((400*HZ)/1000)
0028 
0029 /* ======================================================================== */
0030 /* Hardware register sets & bits                                            */
0031 /* ======================================================================== */
0032 
0033 struct mpc52xx_fec {
0034     u32 fec_id;         /* FEC + 0x000 */
0035     u32 ievent;         /* FEC + 0x004 */
0036     u32 imask;          /* FEC + 0x008 */
0037 
0038     u32 reserved0[1];       /* FEC + 0x00C */
0039     u32 r_des_active;       /* FEC + 0x010 */
0040     u32 x_des_active;       /* FEC + 0x014 */
0041     u32 r_des_active_cl;        /* FEC + 0x018 */
0042     u32 x_des_active_cl;        /* FEC + 0x01C */
0043     u32 ivent_set;          /* FEC + 0x020 */
0044     u32 ecntrl;         /* FEC + 0x024 */
0045 
0046     u32 reserved1[6];       /* FEC + 0x028-03C */
0047     u32 mii_data;           /* FEC + 0x040 */
0048     u32 mii_speed;          /* FEC + 0x044 */
0049     u32 mii_status;         /* FEC + 0x048 */
0050 
0051     u32 reserved2[5];       /* FEC + 0x04C-05C */
0052     u32 mib_data;           /* FEC + 0x060 */
0053     u32 mib_control;        /* FEC + 0x064 */
0054 
0055     u32 reserved3[6];       /* FEC + 0x068-7C */
0056     u32 r_activate;         /* FEC + 0x080 */
0057     u32 r_cntrl;            /* FEC + 0x084 */
0058     u32 r_hash;         /* FEC + 0x088 */
0059     u32 r_data;         /* FEC + 0x08C */
0060     u32 ar_done;            /* FEC + 0x090 */
0061     u32 r_test;         /* FEC + 0x094 */
0062     u32 r_mib;          /* FEC + 0x098 */
0063     u32 r_da_low;           /* FEC + 0x09C */
0064     u32 r_da_high;          /* FEC + 0x0A0 */
0065 
0066     u32 reserved4[7];       /* FEC + 0x0A4-0BC */
0067     u32 x_activate;         /* FEC + 0x0C0 */
0068     u32 x_cntrl;            /* FEC + 0x0C4 */
0069     u32 backoff;            /* FEC + 0x0C8 */
0070     u32 x_data;         /* FEC + 0x0CC */
0071     u32 x_status;           /* FEC + 0x0D0 */
0072     u32 x_mib;          /* FEC + 0x0D4 */
0073     u32 x_test;         /* FEC + 0x0D8 */
0074     u32 fdxfc_da1;          /* FEC + 0x0DC */
0075     u32 fdxfc_da2;          /* FEC + 0x0E0 */
0076     u32 paddr1;         /* FEC + 0x0E4 */
0077     u32 paddr2;         /* FEC + 0x0E8 */
0078     u32 op_pause;           /* FEC + 0x0EC */
0079 
0080     u32 reserved5[4];       /* FEC + 0x0F0-0FC */
0081     u32 instr_reg;          /* FEC + 0x100 */
0082     u32 context_reg;        /* FEC + 0x104 */
0083     u32 test_cntrl;         /* FEC + 0x108 */
0084     u32 acc_reg;            /* FEC + 0x10C */
0085     u32 ones;           /* FEC + 0x110 */
0086     u32 zeros;          /* FEC + 0x114 */
0087     u32 iaddr1;         /* FEC + 0x118 */
0088     u32 iaddr2;         /* FEC + 0x11C */
0089     u32 gaddr1;         /* FEC + 0x120 */
0090     u32 gaddr2;         /* FEC + 0x124 */
0091     u32 random;         /* FEC + 0x128 */
0092     u32 rand1;          /* FEC + 0x12C */
0093     u32 tmp;            /* FEC + 0x130 */
0094 
0095     u32 reserved6[3];       /* FEC + 0x134-13C */
0096     u32 fifo_id;            /* FEC + 0x140 */
0097     u32 x_wmrk;         /* FEC + 0x144 */
0098     u32 fcntrl;         /* FEC + 0x148 */
0099     u32 r_bound;            /* FEC + 0x14C */
0100     u32 r_fstart;           /* FEC + 0x150 */
0101     u32 r_count;            /* FEC + 0x154 */
0102     u32 r_lag;          /* FEC + 0x158 */
0103     u32 r_read;         /* FEC + 0x15C */
0104     u32 r_write;            /* FEC + 0x160 */
0105     u32 x_count;            /* FEC + 0x164 */
0106     u32 x_lag;          /* FEC + 0x168 */
0107     u32 x_retry;            /* FEC + 0x16C */
0108     u32 x_write;            /* FEC + 0x170 */
0109     u32 x_read;         /* FEC + 0x174 */
0110 
0111     u32 reserved7[2];       /* FEC + 0x178-17C */
0112     u32 fm_cntrl;           /* FEC + 0x180 */
0113     u32 rfifo_data;         /* FEC + 0x184 */
0114     u32 rfifo_status;       /* FEC + 0x188 */
0115     u32 rfifo_cntrl;        /* FEC + 0x18C */
0116     u32 rfifo_lrf_ptr;      /* FEC + 0x190 */
0117     u32 rfifo_lwf_ptr;      /* FEC + 0x194 */
0118     u32 rfifo_alarm;        /* FEC + 0x198 */
0119     u32 rfifo_rdptr;        /* FEC + 0x19C */
0120     u32 rfifo_wrptr;        /* FEC + 0x1A0 */
0121     u32 tfifo_data;         /* FEC + 0x1A4 */
0122     u32 tfifo_status;       /* FEC + 0x1A8 */
0123     u32 tfifo_cntrl;        /* FEC + 0x1AC */
0124     u32 tfifo_lrf_ptr;      /* FEC + 0x1B0 */
0125     u32 tfifo_lwf_ptr;      /* FEC + 0x1B4 */
0126     u32 tfifo_alarm;        /* FEC + 0x1B8 */
0127     u32 tfifo_rdptr;        /* FEC + 0x1BC */
0128     u32 tfifo_wrptr;        /* FEC + 0x1C0 */
0129 
0130     u32 reset_cntrl;        /* FEC + 0x1C4 */
0131     u32 xmit_fsm;           /* FEC + 0x1C8 */
0132 
0133     u32 reserved8[3];       /* FEC + 0x1CC-1D4 */
0134     u32 rdes_data0;         /* FEC + 0x1D8 */
0135     u32 rdes_data1;         /* FEC + 0x1DC */
0136     u32 r_length;           /* FEC + 0x1E0 */
0137     u32 x_length;           /* FEC + 0x1E4 */
0138     u32 x_addr;         /* FEC + 0x1E8 */
0139     u32 cdes_data;          /* FEC + 0x1EC */
0140     u32 status;         /* FEC + 0x1F0 */
0141     u32 dma_control;        /* FEC + 0x1F4 */
0142     u32 des_cmnd;           /* FEC + 0x1F8 */
0143     u32 data;           /* FEC + 0x1FC */
0144 
0145     u32 rmon_t_drop;        /* FEC + 0x200 */
0146     u32 rmon_t_packets;     /* FEC + 0x204 */
0147     u32 rmon_t_bc_pkt;      /* FEC + 0x208 */
0148     u32 rmon_t_mc_pkt;      /* FEC + 0x20C */
0149     u32 rmon_t_crc_align;       /* FEC + 0x210 */
0150     u32 rmon_t_undersize;       /* FEC + 0x214 */
0151     u32 rmon_t_oversize;        /* FEC + 0x218 */
0152     u32 rmon_t_frag;        /* FEC + 0x21C */
0153     u32 rmon_t_jab;         /* FEC + 0x220 */
0154     u32 rmon_t_col;         /* FEC + 0x224 */
0155     u32 rmon_t_p64;         /* FEC + 0x228 */
0156     u32 rmon_t_p65to127;        /* FEC + 0x22C */
0157     u32 rmon_t_p128to255;       /* FEC + 0x230 */
0158     u32 rmon_t_p256to511;       /* FEC + 0x234 */
0159     u32 rmon_t_p512to1023;      /* FEC + 0x238 */
0160     u32 rmon_t_p1024to2047;     /* FEC + 0x23C */
0161     u32 rmon_t_p_gte2048;       /* FEC + 0x240 */
0162     u32 rmon_t_octets;      /* FEC + 0x244 */
0163     u32 ieee_t_drop;        /* FEC + 0x248 */
0164     u32 ieee_t_frame_ok;        /* FEC + 0x24C */
0165     u32 ieee_t_1col;        /* FEC + 0x250 */
0166     u32 ieee_t_mcol;        /* FEC + 0x254 */
0167     u32 ieee_t_def;         /* FEC + 0x258 */
0168     u32 ieee_t_lcol;        /* FEC + 0x25C */
0169     u32 ieee_t_excol;       /* FEC + 0x260 */
0170     u32 ieee_t_macerr;      /* FEC + 0x264 */
0171     u32 ieee_t_cserr;       /* FEC + 0x268 */
0172     u32 ieee_t_sqe;         /* FEC + 0x26C */
0173     u32 t_fdxfc;            /* FEC + 0x270 */
0174     u32 ieee_t_octets_ok;       /* FEC + 0x274 */
0175 
0176     u32 reserved9[2];       /* FEC + 0x278-27C */
0177     u32 rmon_r_drop;        /* FEC + 0x280 */
0178     u32 rmon_r_packets;     /* FEC + 0x284 */
0179     u32 rmon_r_bc_pkt;      /* FEC + 0x288 */
0180     u32 rmon_r_mc_pkt;      /* FEC + 0x28C */
0181     u32 rmon_r_crc_align;       /* FEC + 0x290 */
0182     u32 rmon_r_undersize;       /* FEC + 0x294 */
0183     u32 rmon_r_oversize;        /* FEC + 0x298 */
0184     u32 rmon_r_frag;        /* FEC + 0x29C */
0185     u32 rmon_r_jab;         /* FEC + 0x2A0 */
0186 
0187     u32 rmon_r_resvd_0;     /* FEC + 0x2A4 */
0188 
0189     u32 rmon_r_p64;         /* FEC + 0x2A8 */
0190     u32 rmon_r_p65to127;        /* FEC + 0x2AC */
0191     u32 rmon_r_p128to255;       /* FEC + 0x2B0 */
0192     u32 rmon_r_p256to511;       /* FEC + 0x2B4 */
0193     u32 rmon_r_p512to1023;      /* FEC + 0x2B8 */
0194     u32 rmon_r_p1024to2047;     /* FEC + 0x2BC */
0195     u32 rmon_r_p_gte2048;       /* FEC + 0x2C0 */
0196     u32 rmon_r_octets;      /* FEC + 0x2C4 */
0197     u32 ieee_r_drop;        /* FEC + 0x2C8 */
0198     u32 ieee_r_frame_ok;        /* FEC + 0x2CC */
0199     u32 ieee_r_crc;         /* FEC + 0x2D0 */
0200     u32 ieee_r_align;       /* FEC + 0x2D4 */
0201     u32 r_macerr;           /* FEC + 0x2D8 */
0202     u32 r_fdxfc;            /* FEC + 0x2DC */
0203     u32 ieee_r_octets_ok;       /* FEC + 0x2E0 */
0204 
0205     u32 reserved10[7];      /* FEC + 0x2E4-2FC */
0206 
0207     u32 reserved11[64];     /* FEC + 0x300-3FF */
0208 };
0209 
0210 #define FEC_MIB_DISABLE         0x80000000
0211 
0212 #define FEC_IEVENT_HBERR        0x80000000
0213 #define FEC_IEVENT_BABR         0x40000000
0214 #define FEC_IEVENT_BABT         0x20000000
0215 #define FEC_IEVENT_GRA          0x10000000
0216 #define FEC_IEVENT_TFINT        0x08000000
0217 #define FEC_IEVENT_MII          0x00800000
0218 #define FEC_IEVENT_LATE_COL     0x00200000
0219 #define FEC_IEVENT_COL_RETRY_LIM    0x00100000
0220 #define FEC_IEVENT_XFIFO_UN     0x00080000
0221 #define FEC_IEVENT_XFIFO_ERROR      0x00040000
0222 #define FEC_IEVENT_RFIFO_ERROR      0x00020000
0223 
0224 #define FEC_IMASK_HBERR         0x80000000
0225 #define FEC_IMASK_BABR          0x40000000
0226 #define FEC_IMASK_BABT          0x20000000
0227 #define FEC_IMASK_GRA           0x10000000
0228 #define FEC_IMASK_MII           0x00800000
0229 #define FEC_IMASK_LATE_COL      0x00200000
0230 #define FEC_IMASK_COL_RETRY_LIM     0x00100000
0231 #define FEC_IMASK_XFIFO_UN      0x00080000
0232 #define FEC_IMASK_XFIFO_ERROR       0x00040000
0233 #define FEC_IMASK_RFIFO_ERROR       0x00020000
0234 
0235 /* all but MII, which is enabled separately */
0236 #define FEC_IMASK_ENABLE    (FEC_IMASK_HBERR | FEC_IMASK_BABR | \
0237         FEC_IMASK_BABT | FEC_IMASK_GRA | FEC_IMASK_LATE_COL | \
0238         FEC_IMASK_COL_RETRY_LIM | FEC_IMASK_XFIFO_UN | \
0239         FEC_IMASK_XFIFO_ERROR | FEC_IMASK_RFIFO_ERROR)
0240 
0241 #define FEC_RCNTRL_MAX_FL_SHIFT     16
0242 #define FEC_RCNTRL_LOOP         0x01
0243 #define FEC_RCNTRL_DRT          0x02
0244 #define FEC_RCNTRL_MII_MODE     0x04
0245 #define FEC_RCNTRL_PROM         0x08
0246 #define FEC_RCNTRL_BC_REJ       0x10
0247 #define FEC_RCNTRL_FCE          0x20
0248 
0249 #define FEC_TCNTRL_GTS          0x00000001
0250 #define FEC_TCNTRL_HBC          0x00000002
0251 #define FEC_TCNTRL_FDEN         0x00000004
0252 #define FEC_TCNTRL_TFC_PAUSE        0x00000008
0253 #define FEC_TCNTRL_RFC_PAUSE        0x00000010
0254 
0255 #define FEC_ECNTRL_RESET        0x00000001
0256 #define FEC_ECNTRL_ETHER_EN     0x00000002
0257 
0258 #define FEC_MII_DATA_ST         0x40000000  /* Start frame */
0259 #define FEC_MII_DATA_OP_RD      0x20000000  /* Perform read */
0260 #define FEC_MII_DATA_OP_WR      0x10000000  /* Perform write */
0261 #define FEC_MII_DATA_PA_MSK     0x0f800000  /* PHY Address mask */
0262 #define FEC_MII_DATA_RA_MSK     0x007c0000  /* PHY Register mask */
0263 #define FEC_MII_DATA_TA         0x00020000  /* Turnaround */
0264 #define FEC_MII_DATA_DATAMSK        0x0000ffff  /* PHY data mask */
0265 
0266 #define FEC_MII_READ_FRAME  (FEC_MII_DATA_ST | FEC_MII_DATA_OP_RD | FEC_MII_DATA_TA)
0267 #define FEC_MII_WRITE_FRAME (FEC_MII_DATA_ST | FEC_MII_DATA_OP_WR | FEC_MII_DATA_TA)
0268 
0269 #define FEC_MII_DATA_RA_SHIFT       0x12        /* MII reg addr bits */
0270 #define FEC_MII_DATA_PA_SHIFT       0x17        /* MII PHY addr bits */
0271 
0272 #define FEC_PADDR2_TYPE         0x8808
0273 
0274 #define FEC_OP_PAUSE_OPCODE     0x00010000
0275 
0276 #define FEC_FIFO_WMRK_256B      0x3
0277 
0278 #define FEC_FIFO_STATUS_ERR     0x00400000
0279 #define FEC_FIFO_STATUS_UF      0x00200000
0280 #define FEC_FIFO_STATUS_OF      0x00100000
0281 
0282 #define FEC_FIFO_CNTRL_FRAME        0x08000000
0283 #define FEC_FIFO_CNTRL_LTG_7        0x07000000
0284 
0285 #define FEC_RESET_CNTRL_RESET_FIFO  0x02000000
0286 #define FEC_RESET_CNTRL_ENABLE_IS_RESET 0x01000000
0287 
0288 #define FEC_XMIT_FSM_APPEND_CRC     0x02000000
0289 #define FEC_XMIT_FSM_ENABLE_CRC     0x01000000
0290 
0291 
0292 extern struct platform_driver mpc52xx_fec_mdio_driver;
0293 
0294 #endif  /* __DRIVERS_NET_MPC52XX_FEC_H__ */