123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432 |
- #ifndef __TSEC_H
- #define __TSEC_H
- #include <net.h>
- #include <config.h>
- #include <phy.h>
- #ifndef CONFIG_DM_ETH
- #ifdef CONFIG_LS102XA
- #define TSEC_SIZE 0x40000
- #define TSEC_MDIO_OFFSET 0x40000
- #else
- #define TSEC_SIZE 0x01000
- #define TSEC_MDIO_OFFSET 0x01000
- #endif
- #define CONFIG_SYS_MDIO_BASE_ADDR (MDIO_BASE_ADDR + 0x520)
- #define TSEC_GET_REGS(num, offset) \
- (struct tsec __iomem *)\
- (TSEC_BASE_ADDR + (((num) - 1) * (offset)))
- #define TSEC_GET_REGS_BASE(num) \
- TSEC_GET_REGS((num), TSEC_SIZE)
- #define TSEC_GET_MDIO_REGS(num, offset) \
- (struct tsec_mii_mng __iomem *)\
- (CONFIG_SYS_MDIO_BASE_ADDR + ((num) - 1) * (offset))
- #define TSEC_GET_MDIO_REGS_BASE(num) \
- TSEC_GET_MDIO_REGS((num), TSEC_MDIO_OFFSET)
- #define DEFAULT_MII_NAME "FSL_MDIO"
- #define STD_TSEC_INFO(num) \
- { \
- .regs = TSEC_GET_REGS_BASE(num), \
- .miiregs_sgmii = TSEC_GET_MDIO_REGS_BASE(num), \
- .devname = CONFIG_TSEC##num##_NAME, \
- .phyaddr = TSEC##num##_PHY_ADDR, \
- .flags = TSEC##num##_FLAGS, \
- .mii_devname = DEFAULT_MII_NAME \
- }
- #define SET_STD_TSEC_INFO(x, num) \
- { \
- x.regs = TSEC_GET_REGS_BASE(num); \
- x.miiregs_sgmii = TSEC_GET_MDIO_REGS_BASE(num); \
- x.devname = CONFIG_TSEC##num##_NAME; \
- x.phyaddr = TSEC##num##_PHY_ADDR; \
- x.flags = TSEC##num##_FLAGS;\
- x.mii_devname = DEFAULT_MII_NAME;\
- }
- #endif
- #define MAC_ADDR_LEN 6
- #define TSEC_TIMEOUT 1000
- #define TOUT_LOOP 1000000
- #define TBI_CR 0x00
- #define TBI_SR 0x01
- #define TBI_ANA 0x04
- #define TBI_ANLPBPA 0x05
- #define TBI_ANEX 0x06
- #define TBI_TBICON 0x11
- #define TBICON_CLK_SELECT 0x0020
- #define TBIANA_ASYMMETRIC_PAUSE 0x0100
- #define TBIANA_SYMMETRIC_PAUSE 0x0080
- #define TBIANA_HALF_DUPLEX 0x0040
- #define TBIANA_FULL_DUPLEX 0x0020
- #define TBICR_PHY_RESET 0x8000
- #define TBICR_ANEG_ENABLE 0x1000
- #define TBICR_RESTART_ANEG 0x0200
- #define TBICR_FULL_DUPLEX 0x0100
- #define TBICR_SPEED1_SET 0x0040
- #define MACCFG1_SOFT_RESET 0x80000000
- #define MACCFG1_RESET_RX_MC 0x00080000
- #define MACCFG1_RESET_TX_MC 0x00040000
- #define MACCFG1_RESET_RX_FUN 0x00020000
- #define MACCFG1_RESET_TX_FUN 0x00010000
- #define MACCFG1_LOOPBACK 0x00000100
- #define MACCFG1_RX_FLOW 0x00000020
- #define MACCFG1_TX_FLOW 0x00000010
- #define MACCFG1_SYNCD_RX_EN 0x00000008
- #define MACCFG1_RX_EN 0x00000004
- #define MACCFG1_SYNCD_TX_EN 0x00000002
- #define MACCFG1_TX_EN 0x00000001
- #define MACCFG2_INIT_SETTINGS 0x00007205
- #define MACCFG2_FULL_DUPLEX 0x00000001
- #define MACCFG2_IF 0x00000300
- #define MACCFG2_GMII 0x00000200
- #define MACCFG2_MII 0x00000100
- #define ECNTRL_INIT_SETTINGS 0x00001000
- #define ECNTRL_TBI_MODE 0x00000020
- #define ECNTRL_REDUCED_MODE 0x00000010
- #define ECNTRL_R100 0x00000008
- #define ECNTRL_REDUCED_MII_MODE 0x00000004
- #define ECNTRL_SGMII_MODE 0x00000002
- #ifndef CONFIG_SYS_TBIPA_VALUE
- # define CONFIG_SYS_TBIPA_VALUE 0x1f
- #endif
- #define MRBLR_INIT_SETTINGS PKTSIZE_ALIGN
- #define MINFLR_INIT_SETTINGS 0x00000040
- #define DMACTRL_INIT_SETTINGS 0x000000c3
- #define DMACTRL_GRS 0x00000010
- #define DMACTRL_GTS 0x00000008
- #define DMACTRL_LE 0x00008000
- #define TSTAT_CLEAR_THALT 0x80000000
- #define RSTAT_CLEAR_RHALT 0x00800000
- #define IEVENT_INIT_CLEAR 0xffffffff
- #define IEVENT_BABR 0x80000000
- #define IEVENT_RXC 0x40000000
- #define IEVENT_BSY 0x20000000
- #define IEVENT_EBERR 0x10000000
- #define IEVENT_MSRO 0x04000000
- #define IEVENT_GTSC 0x02000000
- #define IEVENT_BABT 0x01000000
- #define IEVENT_TXC 0x00800000
- #define IEVENT_TXE 0x00400000
- #define IEVENT_TXB 0x00200000
- #define IEVENT_TXF 0x00100000
- #define IEVENT_IE 0x00080000
- #define IEVENT_LC 0x00040000
- #define IEVENT_CRL 0x00020000
- #define IEVENT_XFUN 0x00010000
- #define IEVENT_RXB0 0x00008000
- #define IEVENT_GRSC 0x00000100
- #define IEVENT_RXF0 0x00000080
- #define IMASK_INIT_CLEAR 0x00000000
- #define IMASK_TXEEN 0x00400000
- #define IMASK_TXBEN 0x00200000
- #define IMASK_TXFEN 0x00100000
- #define IMASK_RXFEN0 0x00000080
- #define ATTR_INIT_SETTINGS 0x000000c0
- #define ATTRELI_INIT_SETTINGS 0x00000000
- #define TXBD_READY 0x8000
- #define TXBD_PADCRC 0x4000
- #define TXBD_WRAP 0x2000
- #define TXBD_INTERRUPT 0x1000
- #define TXBD_LAST 0x0800
- #define TXBD_CRC 0x0400
- #define TXBD_DEF 0x0200
- #define TXBD_HUGEFRAME 0x0080
- #define TXBD_LATECOLLISION 0x0080
- #define TXBD_RETRYLIMIT 0x0040
- #define TXBD_RETRYCOUNTMASK 0x003c
- #define TXBD_UNDERRUN 0x0002
- #define TXBD_STATS 0x03ff
- #define RXBD_EMPTY 0x8000
- #define RXBD_RO1 0x4000
- #define RXBD_WRAP 0x2000
- #define RXBD_INTERRUPT 0x1000
- #define RXBD_LAST 0x0800
- #define RXBD_FIRST 0x0400
- #define RXBD_MISS 0x0100
- #define RXBD_BROADCAST 0x0080
- #define RXBD_MULTICAST 0x0040
- #define RXBD_LARGE 0x0020
- #define RXBD_NONOCTET 0x0010
- #define RXBD_SHORT 0x0008
- #define RXBD_CRCERR 0x0004
- #define RXBD_OVERRUN 0x0002
- #define RXBD_TRUNCATED 0x0001
- #define RXBD_STATS 0x003f
- struct txbd8 {
- uint16_t status;
- uint16_t length;
- uint32_t bufptr;
- };
- struct rxbd8 {
- uint16_t status;
- uint16_t length;
- uint32_t bufptr;
- };
- struct tsec_rmon_mib {
-
- u32 tr64;
- u32 tr127;
- u32 tr255;
- u32 tr511;
- u32 tr1k;
- u32 trmax;
- u32 trmgv;
-
- u32 rbyt;
- u32 rpkt;
- u32 rfcs;
- u32 rmca;
- u32 rbca;
- u32 rxcf;
- u32 rxpf;
- u32 rxuo;
- u32 raln;
- u32 rflr;
- u32 rcde;
- u32 rcse;
- u32 rund;
- u32 rovr;
- u32 rfrg;
- u32 rjbr;
- u32 rdrp;
-
- u32 tbyt;
- u32 tpkt;
- u32 tmca;
- u32 tbca;
- u32 txpf;
- u32 tdfr;
- u32 tedf;
- u32 tscl;
-
- u32 tmcl;
- u32 tlcl;
- u32 txcl;
- u32 tncl;
- u32 res2;
- u32 tdrp;
- u32 tjbr;
- u32 tfcs;
- u32 txcf;
- u32 tovr;
- u32 tund;
- u32 tfrg;
-
- u32 car1;
- u32 car2;
- u32 cam1;
- u32 cam2;
- };
- struct tsec_hash_regs {
- u32 iaddr0;
- u32 iaddr1;
- u32 iaddr2;
- u32 iaddr3;
- u32 iaddr4;
- u32 iaddr5;
- u32 iaddr6;
- u32 iaddr7;
- u32 res1[24];
- u32 gaddr0;
- u32 gaddr1;
- u32 gaddr2;
- u32 gaddr3;
- u32 gaddr4;
- u32 gaddr5;
- u32 gaddr6;
- u32 gaddr7;
- u32 res2[24];
- };
- struct tsec {
-
- u32 res000[4];
- u32 ievent;
- u32 imask;
- u32 edis;
- u32 res01c;
- u32 ecntrl;
- u32 minflr;
- u32 ptv;
- u32 dmactrl;
- u32 tbipa;
- u32 res034[3];
- u32 res040[48];
-
- u32 tctrl;
- u32 tstat;
- u32 res108;
- u32 tbdlen;
- u32 res110[5];
- u32 ctbptr;
- u32 res128[23];
- u32 tbptr;
- u32 res188[30];
-
- u32 res200;
- u32 tbase;
- u32 res208[42];
- u32 ostbd;
- u32 ostbdp;
- u32 res2b8[18];
-
- u32 rctrl;
- u32 rstat;
- u32 res308;
- u32 rbdlen;
- u32 res310[4];
- u32 res320;
- u32 crbptr;
- u32 res328[6];
- u32 mrblr;
- u32 res344[16];
- u32 rbptr;
- u32 res388[30];
-
- u32 res400;
- u32 rbase;
- u32 res408[62];
-
- u32 maccfg1;
- u32 maccfg2;
- u32 ipgifg;
- u32 hafdup;
- u32 maxfrm;
- u32 res514;
- u32 res518;
- u32 res51c;
- u32 resmdio[6];
- u32 res538;
- u32 ifstat;
- u32 macstnaddr1;
- u32 macstnaddr2;
- u32 res548[46];
-
- u32 res600[32];
-
- struct tsec_rmon_mib rmon;
- u32 res740[48];
-
- struct tsec_hash_regs hash;
- u32 res900[128];
-
- u32 resb00[62];
- u32 attr;
- u32 attreli;
-
- u32 resc00[256];
- };
- #define TSEC_GIGABIT (1 << 0)
- #define TSEC_REDUCED (1 << 1)
- #define TSEC_SGMII (1 << 2)
- #define TX_BUF_CNT 2
- struct tsec_private {
- struct txbd8 __iomem txbd[TX_BUF_CNT];
- struct rxbd8 __iomem rxbd[PKTBUFSRX];
- struct tsec __iomem *regs;
- struct tsec_mii_mng __iomem *phyregs_sgmii;
- struct phy_device *phydev;
- phy_interface_t interface;
- struct mii_dev *bus;
- uint phyaddr;
- uint tbiaddr;
- char mii_devname[16];
- u32 flags;
- uint rx_idx;
- uint tx_idx;
- #ifndef CONFIG_DM_ETH
- struct eth_device *dev;
- #else
- struct udevice *dev;
- #endif
- };
- struct tsec_info_struct {
- struct tsec __iomem *regs;
- struct tsec_mii_mng __iomem *miiregs_sgmii;
- char *devname;
- char *mii_devname;
- phy_interface_t interface;
- unsigned int phyaddr;
- u32 flags;
- };
- #ifndef CONFIG_DM_ETH
- int tsec_standard_init(bd_t *bis);
- int tsec_eth_init(bd_t *bis, struct tsec_info_struct *tsec_info, int num);
- #endif
- #endif
|