1d2912cb1SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */ 29f2f381fSJeff Kirsher /* 39f2f381fSJeff Kirsher * Atmel MACB Ethernet Controller driver 49f2f381fSJeff Kirsher * 59f2f381fSJeff Kirsher * Copyright (C) 2004-2006 Atmel Corporation 69f2f381fSJeff Kirsher */ 79f2f381fSJeff Kirsher #ifndef _MACB_H 89f2f381fSJeff Kirsher #define _MACB_H 99f2f381fSJeff Kirsher 1020c168beSAlexandre Belloni #include <linux/clk.h> 117897b071SAntoine Tenart #include <linux/phylink.h> 12ab91f0a9SRafal Ozieblo #include <linux/ptp_clock_kernel.h> 13ab91f0a9SRafal Ozieblo #include <linux/net_tstamp.h> 14032dc41bSHarini Katakam #include <linux/interrupt.h> 15fc182b85SRussell King 167b429614SRafal Ozieblo #if defined(CONFIG_ARCH_DMA_ADDR_T_64BIT) || defined(CONFIG_MACB_USE_HWSTAMP) 177b429614SRafal Ozieblo #define MACB_EXT_DESC 187b429614SRafal Ozieblo #endif 197b429614SRafal Ozieblo 20d1d1b53dSNicolas Ferre #define MACB_GREGS_NBR 16 217c39994fSNicolas Ferre #define MACB_GREGS_VERSION 2 2202c958ddSCyrille Pitchen #define MACB_MAX_QUEUES 8 23d1d1b53dSNicolas Ferre 249f2f381fSJeff Kirsher /* MACB register offsets */ 255c2fa0f6SXander Huff #define MACB_NCR 0x0000 /* Network Control */ 265c2fa0f6SXander Huff #define MACB_NCFGR 0x0004 /* Network Config */ 275c2fa0f6SXander Huff #define MACB_NSR 0x0008 /* Network Status */ 281fd3ca4eSJoachim Eastwood #define MACB_TAR 0x000c /* AT91RM9200 only */ 291fd3ca4eSJoachim Eastwood #define MACB_TCR 0x0010 /* AT91RM9200 only */ 305c2fa0f6SXander Huff #define MACB_TSR 0x0014 /* Transmit Status */ 315c2fa0f6SXander Huff #define MACB_RBQP 0x0018 /* RX Q Base Address */ 325c2fa0f6SXander Huff #define MACB_TBQP 0x001c /* TX Q Base Address */ 335c2fa0f6SXander Huff #define MACB_RSR 0x0020 /* Receive Status */ 345c2fa0f6SXander Huff #define MACB_ISR 0x0024 /* Interrupt Status */ 355c2fa0f6SXander Huff #define MACB_IER 0x0028 /* Interrupt Enable */ 365c2fa0f6SXander Huff #define MACB_IDR 0x002c /* Interrupt Disable */ 375c2fa0f6SXander Huff #define MACB_IMR 0x0030 /* Interrupt Mask */ 385c2fa0f6SXander Huff #define MACB_MAN 0x0034 /* PHY Maintenance */ 399f2f381fSJeff Kirsher #define MACB_PTR 0x0038 409f2f381fSJeff Kirsher #define MACB_PFR 0x003c 419f2f381fSJeff Kirsher #define MACB_FTO 0x0040 429f2f381fSJeff Kirsher #define MACB_SCF 0x0044 439f2f381fSJeff Kirsher #define MACB_MCF 0x0048 449f2f381fSJeff Kirsher #define MACB_FRO 0x004c 459f2f381fSJeff Kirsher #define MACB_FCSE 0x0050 469f2f381fSJeff Kirsher #define MACB_ALE 0x0054 479f2f381fSJeff Kirsher #define MACB_DTF 0x0058 489f2f381fSJeff Kirsher #define MACB_LCOL 0x005c 499f2f381fSJeff Kirsher #define MACB_EXCOL 0x0060 509f2f381fSJeff Kirsher #define MACB_TUND 0x0064 519f2f381fSJeff Kirsher #define MACB_CSE 0x0068 529f2f381fSJeff Kirsher #define MACB_RRE 0x006c 539f2f381fSJeff Kirsher #define MACB_ROVR 0x0070 549f2f381fSJeff Kirsher #define MACB_RSE 0x0074 559f2f381fSJeff Kirsher #define MACB_ELE 0x0078 569f2f381fSJeff Kirsher #define MACB_RJA 0x007c 579f2f381fSJeff Kirsher #define MACB_USF 0x0080 589f2f381fSJeff Kirsher #define MACB_STE 0x0084 599f2f381fSJeff Kirsher #define MACB_RLE 0x0088 609f2f381fSJeff Kirsher #define MACB_TPF 0x008c 619f2f381fSJeff Kirsher #define MACB_HRB 0x0090 629f2f381fSJeff Kirsher #define MACB_HRT 0x0094 639f2f381fSJeff Kirsher #define MACB_SA1B 0x0098 649f2f381fSJeff Kirsher #define MACB_SA1T 0x009c 659f2f381fSJeff Kirsher #define MACB_SA2B 0x00a0 669f2f381fSJeff Kirsher #define MACB_SA2T 0x00a4 679f2f381fSJeff Kirsher #define MACB_SA3B 0x00a8 689f2f381fSJeff Kirsher #define MACB_SA3T 0x00ac 699f2f381fSJeff Kirsher #define MACB_SA4B 0x00b0 709f2f381fSJeff Kirsher #define MACB_SA4T 0x00b4 719f2f381fSJeff Kirsher #define MACB_TID 0x00b8 729f2f381fSJeff Kirsher #define MACB_TPQ 0x00bc 739f2f381fSJeff Kirsher #define MACB_USRIO 0x00c0 749f2f381fSJeff Kirsher #define MACB_WOL 0x00c4 75f75ba50bSJamie Iles #define MACB_MID 0x00fc 76fff8019aSHarini Katakam #define MACB_TBQPH 0x04C8 77fff8019aSHarini Katakam #define MACB_RBQPH 0x04D4 78f75ba50bSJamie Iles 79f75ba50bSJamie Iles /* GEM register offsets. */ 805c2fa0f6SXander Huff #define GEM_NCFGR 0x0004 /* Network Config */ 815c2fa0f6SXander Huff #define GEM_USRIO 0x000c /* User IO */ 825c2fa0f6SXander Huff #define GEM_DMACFG 0x0010 /* DMA Configuration */ 8398b5a0f4SHarini Katakam #define GEM_JML 0x0048 /* Jumbo Max Length */ 845c2fa0f6SXander Huff #define GEM_HRB 0x0080 /* Hash Bottom */ 855c2fa0f6SXander Huff #define GEM_HRT 0x0084 /* Hash Top */ 865c2fa0f6SXander Huff #define GEM_SA1B 0x0088 /* Specific1 Bottom */ 875c2fa0f6SXander Huff #define GEM_SA1T 0x008C /* Specific1 Top */ 885c2fa0f6SXander Huff #define GEM_SA2B 0x0090 /* Specific2 Bottom */ 895c2fa0f6SXander Huff #define GEM_SA2T 0x0094 /* Specific2 Top */ 905c2fa0f6SXander Huff #define GEM_SA3B 0x0098 /* Specific3 Bottom */ 915c2fa0f6SXander Huff #define GEM_SA3T 0x009C /* Specific3 Top */ 925c2fa0f6SXander Huff #define GEM_SA4B 0x00A0 /* Specific4 Bottom */ 935c2fa0f6SXander Huff #define GEM_SA4T 0x00A4 /* Specific4 Top */ 94558e35ccSNicolas Ferre #define GEM_WOL 0x00b8 /* Wake on LAN */ 95ab91f0a9SRafal Ozieblo #define GEM_EFTSH 0x00e8 /* PTP Event Frame Transmitted Seconds Register 47:32 */ 96ab91f0a9SRafal Ozieblo #define GEM_EFRSH 0x00ec /* PTP Event Frame Received Seconds Register 47:32 */ 97ab91f0a9SRafal Ozieblo #define GEM_PEFTSH 0x00f0 /* PTP Peer Event Frame Transmitted Seconds Register 47:32 */ 98ab91f0a9SRafal Ozieblo #define GEM_PEFRSH 0x00f4 /* PTP Peer Event Frame Received Seconds Register 47:32 */ 995c2fa0f6SXander Huff #define GEM_OTX 0x0100 /* Octets transmitted */ 1006f79eed8SXander Huff #define GEM_OCTTXL 0x0100 /* Octets transmitted [31:0] */ 1016f79eed8SXander Huff #define GEM_OCTTXH 0x0104 /* Octets transmitted [47:32] */ 1026f79eed8SXander Huff #define GEM_TXCNT 0x0108 /* Frames Transmitted counter */ 1036f79eed8SXander Huff #define GEM_TXBCCNT 0x010c /* Broadcast Frames counter */ 1046f79eed8SXander Huff #define GEM_TXMCCNT 0x0110 /* Multicast Frames counter */ 1056f79eed8SXander Huff #define GEM_TXPAUSECNT 0x0114 /* Pause Frames Transmitted Counter */ 1066f79eed8SXander Huff #define GEM_TX64CNT 0x0118 /* 64 byte Frames TX counter */ 1076f79eed8SXander Huff #define GEM_TX65CNT 0x011c /* 65-127 byte Frames TX counter */ 1086f79eed8SXander Huff #define GEM_TX128CNT 0x0120 /* 128-255 byte Frames TX counter */ 1096f79eed8SXander Huff #define GEM_TX256CNT 0x0124 /* 256-511 byte Frames TX counter */ 1106f79eed8SXander Huff #define GEM_TX512CNT 0x0128 /* 512-1023 byte Frames TX counter */ 1116f79eed8SXander Huff #define GEM_TX1024CNT 0x012c /* 1024-1518 byte Frames TX counter */ 1126f79eed8SXander Huff #define GEM_TX1519CNT 0x0130 /* 1519+ byte Frames TX counter */ 1136f79eed8SXander Huff #define GEM_TXURUNCNT 0x0134 /* TX under run error counter */ 1146f79eed8SXander Huff #define GEM_SNGLCOLLCNT 0x0138 /* Single Collision Frame Counter */ 1156f79eed8SXander Huff #define GEM_MULTICOLLCNT 0x013c /* Multiple Collision Frame Counter */ 1166f79eed8SXander Huff #define GEM_EXCESSCOLLCNT 0x0140 /* Excessive Collision Frame Counter */ 1176f79eed8SXander Huff #define GEM_LATECOLLCNT 0x0144 /* Late Collision Frame Counter */ 1186f79eed8SXander Huff #define GEM_TXDEFERCNT 0x0148 /* Deferred Transmission Frame Counter */ 1196f79eed8SXander Huff #define GEM_TXCSENSECNT 0x014c /* Carrier Sense Error Counter */ 1203ff13f1cSXander Huff #define GEM_ORX 0x0150 /* Octets received */ 1216f79eed8SXander Huff #define GEM_OCTRXL 0x0150 /* Octets received [31:0] */ 1226f79eed8SXander Huff #define GEM_OCTRXH 0x0154 /* Octets received [47:32] */ 1236f79eed8SXander Huff #define GEM_RXCNT 0x0158 /* Frames Received Counter */ 1246f79eed8SXander Huff #define GEM_RXBROADCNT 0x015c /* Broadcast Frames Received Counter */ 1256f79eed8SXander Huff #define GEM_RXMULTICNT 0x0160 /* Multicast Frames Received Counter */ 1266f79eed8SXander Huff #define GEM_RXPAUSECNT 0x0164 /* Pause Frames Received Counter */ 1276f79eed8SXander Huff #define GEM_RX64CNT 0x0168 /* 64 byte Frames RX Counter */ 1286f79eed8SXander Huff #define GEM_RX65CNT 0x016c /* 65-127 byte Frames RX Counter */ 1296f79eed8SXander Huff #define GEM_RX128CNT 0x0170 /* 128-255 byte Frames RX Counter */ 1306f79eed8SXander Huff #define GEM_RX256CNT 0x0174 /* 256-511 byte Frames RX Counter */ 1316f79eed8SXander Huff #define GEM_RX512CNT 0x0178 /* 512-1023 byte Frames RX Counter */ 1326f79eed8SXander Huff #define GEM_RX1024CNT 0x017c /* 1024-1518 byte Frames RX Counter */ 1336f79eed8SXander Huff #define GEM_RX1519CNT 0x0180 /* 1519+ byte Frames RX Counter */ 1346f79eed8SXander Huff #define GEM_RXUNDRCNT 0x0184 /* Undersize Frames Received Counter */ 1356f79eed8SXander Huff #define GEM_RXOVRCNT 0x0188 /* Oversize Frames Received Counter */ 1366f79eed8SXander Huff #define GEM_RXJABCNT 0x018c /* Jabbers Received Counter */ 1376f79eed8SXander Huff #define GEM_RXFCSCNT 0x0190 /* Frame Check Sequence Error Counter */ 1386f79eed8SXander Huff #define GEM_RXLENGTHCNT 0x0194 /* Length Field Error Counter */ 1396f79eed8SXander Huff #define GEM_RXSYMBCNT 0x0198 /* Symbol Error Counter */ 1406f79eed8SXander Huff #define GEM_RXALIGNCNT 0x019c /* Alignment Error Counter */ 1416f79eed8SXander Huff #define GEM_RXRESERRCNT 0x01a0 /* Receive Resource Error Counter */ 1426f79eed8SXander Huff #define GEM_RXORCNT 0x01a4 /* Receive Overrun Counter */ 1436f79eed8SXander Huff #define GEM_RXIPCCNT 0x01a8 /* IP header Checksum Error Counter */ 1446f79eed8SXander Huff #define GEM_RXTCPCCNT 0x01ac /* TCP Checksum Error Counter */ 1456f79eed8SXander Huff #define GEM_RXUDPCCNT 0x01b0 /* UDP Checksum Error Counter */ 146c2594d80SAndrei.Pistirica@microchip.com #define GEM_TISUBN 0x01bc /* 1588 Timer Increment Sub-ns */ 147c2594d80SAndrei.Pistirica@microchip.com #define GEM_TSH 0x01c0 /* 1588 Timer Seconds High */ 148c2594d80SAndrei.Pistirica@microchip.com #define GEM_TSL 0x01d0 /* 1588 Timer Seconds Low */ 149c2594d80SAndrei.Pistirica@microchip.com #define GEM_TN 0x01d4 /* 1588 Timer Nanoseconds */ 150c2594d80SAndrei.Pistirica@microchip.com #define GEM_TA 0x01d8 /* 1588 Timer Adjust */ 151c2594d80SAndrei.Pistirica@microchip.com #define GEM_TI 0x01dc /* 1588 Timer Increment */ 152c2594d80SAndrei.Pistirica@microchip.com #define GEM_EFTSL 0x01e0 /* PTP Event Frame Tx Seconds Low */ 153c2594d80SAndrei.Pistirica@microchip.com #define GEM_EFTN 0x01e4 /* PTP Event Frame Tx Nanoseconds */ 154c2594d80SAndrei.Pistirica@microchip.com #define GEM_EFRSL 0x01e8 /* PTP Event Frame Rx Seconds Low */ 155c2594d80SAndrei.Pistirica@microchip.com #define GEM_EFRN 0x01ec /* PTP Event Frame Rx Nanoseconds */ 156c2594d80SAndrei.Pistirica@microchip.com #define GEM_PEFTSL 0x01f0 /* PTP Peer Event Frame Tx Secs Low */ 157c2594d80SAndrei.Pistirica@microchip.com #define GEM_PEFTN 0x01f4 /* PTP Peer Event Frame Tx Ns */ 158c2594d80SAndrei.Pistirica@microchip.com #define GEM_PEFRSL 0x01f8 /* PTP Peer Event Frame Rx Sec Low */ 159c2594d80SAndrei.Pistirica@microchip.com #define GEM_PEFRN 0x01fc /* PTP Peer Event Frame Rx Ns */ 1605c2fa0f6SXander Huff #define GEM_DCFG1 0x0280 /* Design Config 1 */ 1615c2fa0f6SXander Huff #define GEM_DCFG2 0x0284 /* Design Config 2 */ 1625c2fa0f6SXander Huff #define GEM_DCFG3 0x0288 /* Design Config 3 */ 1635c2fa0f6SXander Huff #define GEM_DCFG4 0x028c /* Design Config 4 */ 1645c2fa0f6SXander Huff #define GEM_DCFG5 0x0290 /* Design Config 5 */ 1655c2fa0f6SXander Huff #define GEM_DCFG6 0x0294 /* Design Config 6 */ 1665c2fa0f6SXander Huff #define GEM_DCFG7 0x0298 /* Design Config 7 */ 167ae8223deSRafal Ozieblo #define GEM_DCFG8 0x029C /* Design Config 8 */ 168404cd086SHarini Katakam #define GEM_DCFG10 0x02A4 /* Design Config 10 */ 1699f2f381fSJeff Kirsher 170ab91f0a9SRafal Ozieblo #define GEM_TXBDCTRL 0x04cc /* TX Buffer Descriptor control register */ 171ab91f0a9SRafal Ozieblo #define GEM_RXBDCTRL 0x04d0 /* RX Buffer Descriptor control register */ 172ab91f0a9SRafal Ozieblo 173ae8223deSRafal Ozieblo /* Screener Type 2 match registers */ 174ae8223deSRafal Ozieblo #define GEM_SCRT2 0x540 175ae8223deSRafal Ozieblo 176ae8223deSRafal Ozieblo /* EtherType registers */ 177ae8223deSRafal Ozieblo #define GEM_ETHT 0x06E0 178ae8223deSRafal Ozieblo 179ae8223deSRafal Ozieblo /* Type 2 compare registers */ 180ae8223deSRafal Ozieblo #define GEM_T2CMPW0 0x0700 181ae8223deSRafal Ozieblo #define GEM_T2CMPW1 0x0704 182ae8223deSRafal Ozieblo #define T2CMP_OFST(t2idx) (t2idx * 2) 183ae8223deSRafal Ozieblo 184ae8223deSRafal Ozieblo /* type 2 compare registers 185ae8223deSRafal Ozieblo * each location requires 3 compare regs 186ae8223deSRafal Ozieblo */ 187ae8223deSRafal Ozieblo #define GEM_IP4SRC_CMP(idx) (idx * 3) 188ae8223deSRafal Ozieblo #define GEM_IP4DST_CMP(idx) (idx * 3 + 1) 189ae8223deSRafal Ozieblo #define GEM_PORT_CMP(idx) (idx * 3 + 2) 190ae8223deSRafal Ozieblo 191ae8223deSRafal Ozieblo /* Which screening type 2 EtherType register will be used (0 - 7) */ 192ae8223deSRafal Ozieblo #define SCRT2_ETHT 0 193ae8223deSRafal Ozieblo 19402c958ddSCyrille Pitchen #define GEM_ISR(hw_q) (0x0400 + ((hw_q) << 2)) 19502c958ddSCyrille Pitchen #define GEM_TBQP(hw_q) (0x0440 + ((hw_q) << 2)) 196fff8019aSHarini Katakam #define GEM_TBQPH(hw_q) (0x04C8) 19702c958ddSCyrille Pitchen #define GEM_RBQP(hw_q) (0x0480 + ((hw_q) << 2)) 198ae1f2a56SRafal Ozieblo #define GEM_RBQS(hw_q) (0x04A0 + ((hw_q) << 2)) 199ae1f2a56SRafal Ozieblo #define GEM_RBQPH(hw_q) (0x04D4) 20002c958ddSCyrille Pitchen #define GEM_IER(hw_q) (0x0600 + ((hw_q) << 2)) 20102c958ddSCyrille Pitchen #define GEM_IDR(hw_q) (0x0620 + ((hw_q) << 2)) 20202c958ddSCyrille Pitchen #define GEM_IMR(hw_q) (0x0640 + ((hw_q) << 2)) 20302c958ddSCyrille Pitchen 2049f2f381fSJeff Kirsher /* Bitfields in NCR */ 2055c2fa0f6SXander Huff #define MACB_LB_OFFSET 0 /* reserved */ 2069f2f381fSJeff Kirsher #define MACB_LB_SIZE 1 2075c2fa0f6SXander Huff #define MACB_LLB_OFFSET 1 /* Loop back local */ 2089f2f381fSJeff Kirsher #define MACB_LLB_SIZE 1 2095c2fa0f6SXander Huff #define MACB_RE_OFFSET 2 /* Receive enable */ 2109f2f381fSJeff Kirsher #define MACB_RE_SIZE 1 2115c2fa0f6SXander Huff #define MACB_TE_OFFSET 3 /* Transmit enable */ 2129f2f381fSJeff Kirsher #define MACB_TE_SIZE 1 2135c2fa0f6SXander Huff #define MACB_MPE_OFFSET 4 /* Management port enable */ 2149f2f381fSJeff Kirsher #define MACB_MPE_SIZE 1 2155c2fa0f6SXander Huff #define MACB_CLRSTAT_OFFSET 5 /* Clear stats regs */ 2169f2f381fSJeff Kirsher #define MACB_CLRSTAT_SIZE 1 2175c2fa0f6SXander Huff #define MACB_INCSTAT_OFFSET 6 /* Incremental stats regs */ 2189f2f381fSJeff Kirsher #define MACB_INCSTAT_SIZE 1 2195c2fa0f6SXander Huff #define MACB_WESTAT_OFFSET 7 /* Write enable stats regs */ 2209f2f381fSJeff Kirsher #define MACB_WESTAT_SIZE 1 2215c2fa0f6SXander Huff #define MACB_BP_OFFSET 8 /* Back pressure */ 2229f2f381fSJeff Kirsher #define MACB_BP_SIZE 1 2235c2fa0f6SXander Huff #define MACB_TSTART_OFFSET 9 /* Start transmission */ 2249f2f381fSJeff Kirsher #define MACB_TSTART_SIZE 1 2255c2fa0f6SXander Huff #define MACB_THALT_OFFSET 10 /* Transmit halt */ 2269f2f381fSJeff Kirsher #define MACB_THALT_SIZE 1 2275c2fa0f6SXander Huff #define MACB_NCR_TPF_OFFSET 11 /* Transmit pause frame */ 2289f2f381fSJeff Kirsher #define MACB_NCR_TPF_SIZE 1 2296f79eed8SXander Huff #define MACB_TZQ_OFFSET 12 /* Transmit zero quantum pause frame */ 2309f2f381fSJeff Kirsher #define MACB_TZQ_SIZE 1 231c2594d80SAndrei.Pistirica@microchip.com #define MACB_SRTSM_OFFSET 15 232ab91f0a9SRafal Ozieblo #define MACB_OSSMODE_OFFSET 24 /* Enable One Step Synchro Mode */ 233ab91f0a9SRafal Ozieblo #define MACB_OSSMODE_SIZE 1 2349f2f381fSJeff Kirsher 2359f2f381fSJeff Kirsher /* Bitfields in NCFGR */ 2365c2fa0f6SXander Huff #define MACB_SPD_OFFSET 0 /* Speed */ 2379f2f381fSJeff Kirsher #define MACB_SPD_SIZE 1 2385c2fa0f6SXander Huff #define MACB_FD_OFFSET 1 /* Full duplex */ 2399f2f381fSJeff Kirsher #define MACB_FD_SIZE 1 2405c2fa0f6SXander Huff #define MACB_BIT_RATE_OFFSET 2 /* Discard non-VLAN frames */ 2419f2f381fSJeff Kirsher #define MACB_BIT_RATE_SIZE 1 2425c2fa0f6SXander Huff #define MACB_JFRAME_OFFSET 3 /* reserved */ 2439f2f381fSJeff Kirsher #define MACB_JFRAME_SIZE 1 2445c2fa0f6SXander Huff #define MACB_CAF_OFFSET 4 /* Copy all frames */ 2459f2f381fSJeff Kirsher #define MACB_CAF_SIZE 1 2465c2fa0f6SXander Huff #define MACB_NBC_OFFSET 5 /* No broadcast */ 2479f2f381fSJeff Kirsher #define MACB_NBC_SIZE 1 2485c2fa0f6SXander Huff #define MACB_NCFGR_MTI_OFFSET 6 /* Multicast hash enable */ 2499f2f381fSJeff Kirsher #define MACB_NCFGR_MTI_SIZE 1 2505c2fa0f6SXander Huff #define MACB_UNI_OFFSET 7 /* Unicast hash enable */ 2519f2f381fSJeff Kirsher #define MACB_UNI_SIZE 1 2525c2fa0f6SXander Huff #define MACB_BIG_OFFSET 8 /* Receive 1536 byte frames */ 2539f2f381fSJeff Kirsher #define MACB_BIG_SIZE 1 2546f79eed8SXander Huff #define MACB_EAE_OFFSET 9 /* External address match enable */ 2559f2f381fSJeff Kirsher #define MACB_EAE_SIZE 1 2569f2f381fSJeff Kirsher #define MACB_CLK_OFFSET 10 2579f2f381fSJeff Kirsher #define MACB_CLK_SIZE 2 2585c2fa0f6SXander Huff #define MACB_RTY_OFFSET 12 /* Retry test */ 2599f2f381fSJeff Kirsher #define MACB_RTY_SIZE 1 2605c2fa0f6SXander Huff #define MACB_PAE_OFFSET 13 /* Pause enable */ 2619f2f381fSJeff Kirsher #define MACB_PAE_SIZE 1 2621fd3ca4eSJoachim Eastwood #define MACB_RM9200_RMII_OFFSET 13 /* AT91RM9200 only */ 2631fd3ca4eSJoachim Eastwood #define MACB_RM9200_RMII_SIZE 1 /* AT91RM9200 only */ 2645c2fa0f6SXander Huff #define MACB_RBOF_OFFSET 14 /* Receive buffer offset */ 2659f2f381fSJeff Kirsher #define MACB_RBOF_SIZE 2 2666f79eed8SXander Huff #define MACB_RLCE_OFFSET 16 /* Length field error frame discard */ 2679f2f381fSJeff Kirsher #define MACB_RLCE_SIZE 1 2685c2fa0f6SXander Huff #define MACB_DRFCS_OFFSET 17 /* FCS remove */ 2699f2f381fSJeff Kirsher #define MACB_DRFCS_SIZE 1 2709f2f381fSJeff Kirsher #define MACB_EFRHD_OFFSET 18 2719f2f381fSJeff Kirsher #define MACB_EFRHD_SIZE 1 2729f2f381fSJeff Kirsher #define MACB_IRXFCS_OFFSET 19 2739f2f381fSJeff Kirsher #define MACB_IRXFCS_SIZE 1 2749f2f381fSJeff Kirsher 27570c9f3d4SJamie Iles /* GEM specific NCFGR bitfields. */ 2765c2fa0f6SXander Huff #define GEM_GBE_OFFSET 10 /* Gigabit mode enable */ 277140b7552SPatrice Vilchez #define GEM_GBE_SIZE 1 278022be25cSPunnaiah Choudary Kalluri #define GEM_PCSSEL_OFFSET 11 279022be25cSPunnaiah Choudary Kalluri #define GEM_PCSSEL_SIZE 1 2805c2fa0f6SXander Huff #define GEM_CLK_OFFSET 18 /* MDC clock division */ 28170c9f3d4SJamie Iles #define GEM_CLK_SIZE 3 2825c2fa0f6SXander Huff #define GEM_DBW_OFFSET 21 /* Data bus width */ 283757a03c6SJamie Iles #define GEM_DBW_SIZE 2 284924ec53cSCyrille Pitchen #define GEM_RXCOEN_OFFSET 24 285924ec53cSCyrille Pitchen #define GEM_RXCOEN_SIZE 1 286022be25cSPunnaiah Choudary Kalluri #define GEM_SGMIIEN_OFFSET 27 287022be25cSPunnaiah Choudary Kalluri #define GEM_SGMIIEN_SIZE 1 288022be25cSPunnaiah Choudary Kalluri 289757a03c6SJamie Iles 290757a03c6SJamie Iles /* Constants for data bus width. */ 2916f79eed8SXander Huff #define GEM_DBW32 0 /* 32 bit AMBA AHB data bus width */ 2926f79eed8SXander Huff #define GEM_DBW64 1 /* 64 bit AMBA AHB data bus width */ 2936f79eed8SXander Huff #define GEM_DBW128 2 /* 128 bit AMBA AHB data bus width */ 294757a03c6SJamie Iles 2950116da4fSJamie Iles /* Bitfields in DMACFG. */ 2966f79eed8SXander Huff #define GEM_FBLDO_OFFSET 0 /* fixed burst length for DMA */ 297b3e3bd71SNicolas Ferre #define GEM_FBLDO_SIZE 5 298a50dad35SArun Chandran #define GEM_ENDIA_DESC_OFFSET 6 /* endian swap mode for management descriptor access */ 299ea373041SArun Chandran #define GEM_ENDIA_DESC_SIZE 1 300a50dad35SArun Chandran #define GEM_ENDIA_PKT_OFFSET 7 /* endian swap mode for packet data access */ 301ea373041SArun Chandran #define GEM_ENDIA_PKT_SIZE 1 3026f79eed8SXander Huff #define GEM_RXBMS_OFFSET 8 /* RX packet buffer memory size select */ 303b3e3bd71SNicolas Ferre #define GEM_RXBMS_SIZE 2 3046f79eed8SXander Huff #define GEM_TXPBMS_OFFSET 10 /* TX packet buffer memory size select */ 305b3e3bd71SNicolas Ferre #define GEM_TXPBMS_SIZE 1 3066f79eed8SXander Huff #define GEM_TXCOEN_OFFSET 11 /* TX IP/TCP/UDP checksum gen offload */ 307b3e3bd71SNicolas Ferre #define GEM_TXCOEN_SIZE 1 3086f79eed8SXander Huff #define GEM_RXBS_OFFSET 16 /* DMA receive buffer size */ 3090116da4fSJamie Iles #define GEM_RXBS_SIZE 8 3105c2fa0f6SXander Huff #define GEM_DDRP_OFFSET 24 /* disc_when_no_ahb */ 311b3e3bd71SNicolas Ferre #define GEM_DDRP_SIZE 1 3127b429614SRafal Ozieblo #define GEM_RXEXT_OFFSET 28 /* RX extended Buffer Descriptor mode */ 3137b429614SRafal Ozieblo #define GEM_RXEXT_SIZE 1 3147b429614SRafal Ozieblo #define GEM_TXEXT_OFFSET 29 /* TX extended Buffer Descriptor mode */ 3157b429614SRafal Ozieblo #define GEM_TXEXT_SIZE 1 316fff8019aSHarini Katakam #define GEM_ADDR64_OFFSET 30 /* Address bus width - 64b or 32b */ 317fff8019aSHarini Katakam #define GEM_ADDR64_SIZE 1 318b3e3bd71SNicolas Ferre 3190116da4fSJamie Iles 3209f2f381fSJeff Kirsher /* Bitfields in NSR */ 3215c2fa0f6SXander Huff #define MACB_NSR_LINK_OFFSET 0 /* pcs_link_state */ 3229f2f381fSJeff Kirsher #define MACB_NSR_LINK_SIZE 1 3236f79eed8SXander Huff #define MACB_MDIO_OFFSET 1 /* status of the mdio_in pin */ 3249f2f381fSJeff Kirsher #define MACB_MDIO_SIZE 1 3256f79eed8SXander Huff #define MACB_IDLE_OFFSET 2 /* The PHY management logic is idle */ 3269f2f381fSJeff Kirsher #define MACB_IDLE_SIZE 1 3279f2f381fSJeff Kirsher 3289f2f381fSJeff Kirsher /* Bitfields in TSR */ 3295c2fa0f6SXander Huff #define MACB_UBR_OFFSET 0 /* Used bit read */ 3309f2f381fSJeff Kirsher #define MACB_UBR_SIZE 1 3315c2fa0f6SXander Huff #define MACB_COL_OFFSET 1 /* Collision occurred */ 3329f2f381fSJeff Kirsher #define MACB_COL_SIZE 1 3335c2fa0f6SXander Huff #define MACB_TSR_RLE_OFFSET 2 /* Retry limit exceeded */ 3349f2f381fSJeff Kirsher #define MACB_TSR_RLE_SIZE 1 3355c2fa0f6SXander Huff #define MACB_TGO_OFFSET 3 /* Transmit go */ 3369f2f381fSJeff Kirsher #define MACB_TGO_SIZE 1 3376f79eed8SXander Huff #define MACB_BEX_OFFSET 4 /* TX frame corruption due to AHB error */ 3389f2f381fSJeff Kirsher #define MACB_BEX_SIZE 1 3391fd3ca4eSJoachim Eastwood #define MACB_RM9200_BNQ_OFFSET 4 /* AT91RM9200 only */ 3401fd3ca4eSJoachim Eastwood #define MACB_RM9200_BNQ_SIZE 1 /* AT91RM9200 only */ 3415c2fa0f6SXander Huff #define MACB_COMP_OFFSET 5 /* Trnasmit complete */ 3429f2f381fSJeff Kirsher #define MACB_COMP_SIZE 1 3435c2fa0f6SXander Huff #define MACB_UND_OFFSET 6 /* Trnasmit under run */ 3449f2f381fSJeff Kirsher #define MACB_UND_SIZE 1 3459f2f381fSJeff Kirsher 3469f2f381fSJeff Kirsher /* Bitfields in RSR */ 3475c2fa0f6SXander Huff #define MACB_BNA_OFFSET 0 /* Buffer not available */ 3489f2f381fSJeff Kirsher #define MACB_BNA_SIZE 1 3495c2fa0f6SXander Huff #define MACB_REC_OFFSET 1 /* Frame received */ 3509f2f381fSJeff Kirsher #define MACB_REC_SIZE 1 3515c2fa0f6SXander Huff #define MACB_OVR_OFFSET 2 /* Receive overrun */ 3529f2f381fSJeff Kirsher #define MACB_OVR_SIZE 1 3539f2f381fSJeff Kirsher 3549f2f381fSJeff Kirsher /* Bitfields in ISR/IER/IDR/IMR */ 3555c2fa0f6SXander Huff #define MACB_MFD_OFFSET 0 /* Management frame sent */ 3569f2f381fSJeff Kirsher #define MACB_MFD_SIZE 1 3575c2fa0f6SXander Huff #define MACB_RCOMP_OFFSET 1 /* Receive complete */ 3589f2f381fSJeff Kirsher #define MACB_RCOMP_SIZE 1 3595c2fa0f6SXander Huff #define MACB_RXUBR_OFFSET 2 /* RX used bit read */ 3609f2f381fSJeff Kirsher #define MACB_RXUBR_SIZE 1 3615c2fa0f6SXander Huff #define MACB_TXUBR_OFFSET 3 /* TX used bit read */ 3629f2f381fSJeff Kirsher #define MACB_TXUBR_SIZE 1 3636f79eed8SXander Huff #define MACB_ISR_TUND_OFFSET 4 /* Enable TX buffer under run interrupt */ 3649f2f381fSJeff Kirsher #define MACB_ISR_TUND_SIZE 1 3656f79eed8SXander Huff #define MACB_ISR_RLE_OFFSET 5 /* EN retry exceeded/late coll interrupt */ 3669f2f381fSJeff Kirsher #define MACB_ISR_RLE_SIZE 1 3676f79eed8SXander Huff #define MACB_TXERR_OFFSET 6 /* EN TX frame corrupt from error interrupt */ 3689f2f381fSJeff Kirsher #define MACB_TXERR_SIZE 1 369*fa6031dfSWilly Tarreau #define MACB_RM9200_TBRE_OFFSET 6 /* EN may send new frame interrupt (RM9200) */ 370*fa6031dfSWilly Tarreau #define MACB_RM9200_TBRE_SIZE 1 3716f79eed8SXander Huff #define MACB_TCOMP_OFFSET 7 /* Enable transmit complete interrupt */ 3729f2f381fSJeff Kirsher #define MACB_TCOMP_SIZE 1 3736f79eed8SXander Huff #define MACB_ISR_LINK_OFFSET 9 /* Enable link change interrupt */ 3749f2f381fSJeff Kirsher #define MACB_ISR_LINK_SIZE 1 3756f79eed8SXander Huff #define MACB_ISR_ROVR_OFFSET 10 /* Enable receive overrun interrupt */ 3769f2f381fSJeff Kirsher #define MACB_ISR_ROVR_SIZE 1 3776f79eed8SXander Huff #define MACB_HRESP_OFFSET 11 /* Enable hrsep not OK interrupt */ 3789f2f381fSJeff Kirsher #define MACB_HRESP_SIZE 1 3796f79eed8SXander Huff #define MACB_PFR_OFFSET 12 /* Enable pause frame w/ quantum interrupt */ 3809f2f381fSJeff Kirsher #define MACB_PFR_SIZE 1 3816f79eed8SXander Huff #define MACB_PTZ_OFFSET 13 /* Enable pause time zero interrupt */ 3829f2f381fSJeff Kirsher #define MACB_PTZ_SIZE 1 3833e2a5e15SSergio Prado #define MACB_WOL_OFFSET 14 /* Enable wake-on-lan interrupt */ 3843e2a5e15SSergio Prado #define MACB_WOL_SIZE 1 385c2594d80SAndrei.Pistirica@microchip.com #define MACB_DRQFR_OFFSET 18 /* PTP Delay Request Frame Received */ 386c2594d80SAndrei.Pistirica@microchip.com #define MACB_DRQFR_SIZE 1 387c2594d80SAndrei.Pistirica@microchip.com #define MACB_SFR_OFFSET 19 /* PTP Sync Frame Received */ 388c2594d80SAndrei.Pistirica@microchip.com #define MACB_SFR_SIZE 1 389c2594d80SAndrei.Pistirica@microchip.com #define MACB_DRQFT_OFFSET 20 /* PTP Delay Request Frame Transmitted */ 390c2594d80SAndrei.Pistirica@microchip.com #define MACB_DRQFT_SIZE 1 391c2594d80SAndrei.Pistirica@microchip.com #define MACB_SFT_OFFSET 21 /* PTP Sync Frame Transmitted */ 392c2594d80SAndrei.Pistirica@microchip.com #define MACB_SFT_SIZE 1 393c2594d80SAndrei.Pistirica@microchip.com #define MACB_PDRQFR_OFFSET 22 /* PDelay Request Frame Received */ 394c2594d80SAndrei.Pistirica@microchip.com #define MACB_PDRQFR_SIZE 1 395c2594d80SAndrei.Pistirica@microchip.com #define MACB_PDRSFR_OFFSET 23 /* PDelay Response Frame Received */ 396c2594d80SAndrei.Pistirica@microchip.com #define MACB_PDRSFR_SIZE 1 397c2594d80SAndrei.Pistirica@microchip.com #define MACB_PDRQFT_OFFSET 24 /* PDelay Request Frame Transmitted */ 398c2594d80SAndrei.Pistirica@microchip.com #define MACB_PDRQFT_SIZE 1 399c2594d80SAndrei.Pistirica@microchip.com #define MACB_PDRSFT_OFFSET 25 /* PDelay Response Frame Transmitted */ 400c2594d80SAndrei.Pistirica@microchip.com #define MACB_PDRSFT_SIZE 1 401c2594d80SAndrei.Pistirica@microchip.com #define MACB_SRI_OFFSET 26 /* TSU Seconds Register Increment */ 402c2594d80SAndrei.Pistirica@microchip.com #define MACB_SRI_SIZE 1 403558e35ccSNicolas Ferre #define GEM_WOL_OFFSET 28 /* Enable wake-on-lan interrupt */ 404558e35ccSNicolas Ferre #define GEM_WOL_SIZE 1 405c2594d80SAndrei.Pistirica@microchip.com 406c2594d80SAndrei.Pistirica@microchip.com /* Timer increment fields */ 407c2594d80SAndrei.Pistirica@microchip.com #define MACB_TI_CNS_OFFSET 0 408c2594d80SAndrei.Pistirica@microchip.com #define MACB_TI_CNS_SIZE 8 409c2594d80SAndrei.Pistirica@microchip.com #define MACB_TI_ACNS_OFFSET 8 410c2594d80SAndrei.Pistirica@microchip.com #define MACB_TI_ACNS_SIZE 8 411c2594d80SAndrei.Pistirica@microchip.com #define MACB_TI_NIT_OFFSET 16 412c2594d80SAndrei.Pistirica@microchip.com #define MACB_TI_NIT_SIZE 8 4139f2f381fSJeff Kirsher 4149f2f381fSJeff Kirsher /* Bitfields in MAN */ 4155c2fa0f6SXander Huff #define MACB_DATA_OFFSET 0 /* data */ 4169f2f381fSJeff Kirsher #define MACB_DATA_SIZE 16 4175c2fa0f6SXander Huff #define MACB_CODE_OFFSET 16 /* Must be written to 10 */ 4189f2f381fSJeff Kirsher #define MACB_CODE_SIZE 2 4195c2fa0f6SXander Huff #define MACB_REGA_OFFSET 18 /* Register address */ 4209f2f381fSJeff Kirsher #define MACB_REGA_SIZE 5 4215c2fa0f6SXander Huff #define MACB_PHYA_OFFSET 23 /* PHY address */ 4229f2f381fSJeff Kirsher #define MACB_PHYA_SIZE 5 4236f79eed8SXander Huff #define MACB_RW_OFFSET 28 /* Operation. 10 is read. 01 is write. */ 4249f2f381fSJeff Kirsher #define MACB_RW_SIZE 2 4256f79eed8SXander Huff #define MACB_SOF_OFFSET 30 /* Must be written to 1 for Clause 22 */ 4269f2f381fSJeff Kirsher #define MACB_SOF_SIZE 2 4279f2f381fSJeff Kirsher 4289f2f381fSJeff Kirsher /* Bitfields in USRIO (AVR32) */ 4299f2f381fSJeff Kirsher #define MACB_MII_OFFSET 0 4309f2f381fSJeff Kirsher #define MACB_MII_SIZE 1 4319f2f381fSJeff Kirsher #define MACB_EAM_OFFSET 1 4329f2f381fSJeff Kirsher #define MACB_EAM_SIZE 1 4339f2f381fSJeff Kirsher #define MACB_TX_PAUSE_OFFSET 2 4349f2f381fSJeff Kirsher #define MACB_TX_PAUSE_SIZE 1 4359f2f381fSJeff Kirsher #define MACB_TX_PAUSE_ZERO_OFFSET 3 4369f2f381fSJeff Kirsher #define MACB_TX_PAUSE_ZERO_SIZE 1 4379f2f381fSJeff Kirsher 4389f2f381fSJeff Kirsher /* Bitfields in USRIO (AT91) */ 4399f2f381fSJeff Kirsher #define MACB_RMII_OFFSET 0 4409f2f381fSJeff Kirsher #define MACB_RMII_SIZE 1 441140b7552SPatrice Vilchez #define GEM_RGMII_OFFSET 0 /* GEM gigabit mode */ 442140b7552SPatrice Vilchez #define GEM_RGMII_SIZE 1 4439f2f381fSJeff Kirsher #define MACB_CLKEN_OFFSET 1 4449f2f381fSJeff Kirsher #define MACB_CLKEN_SIZE 1 4459f2f381fSJeff Kirsher 4469f2f381fSJeff Kirsher /* Bitfields in WOL */ 4479f2f381fSJeff Kirsher #define MACB_IP_OFFSET 0 4489f2f381fSJeff Kirsher #define MACB_IP_SIZE 16 4499f2f381fSJeff Kirsher #define MACB_MAG_OFFSET 16 4509f2f381fSJeff Kirsher #define MACB_MAG_SIZE 1 4519f2f381fSJeff Kirsher #define MACB_ARP_OFFSET 17 4529f2f381fSJeff Kirsher #define MACB_ARP_SIZE 1 4539f2f381fSJeff Kirsher #define MACB_SA1_OFFSET 18 4549f2f381fSJeff Kirsher #define MACB_SA1_SIZE 1 4559f2f381fSJeff Kirsher #define MACB_WOL_MTI_OFFSET 19 4569f2f381fSJeff Kirsher #define MACB_WOL_MTI_SIZE 1 4579f2f381fSJeff Kirsher 458f75ba50bSJamie Iles /* Bitfields in MID */ 459f75ba50bSJamie Iles #define MACB_IDNUM_OFFSET 16 460d941bebfSPunnaiah Choudary Kalluri #define MACB_IDNUM_SIZE 12 461f75ba50bSJamie Iles #define MACB_REV_OFFSET 0 462f75ba50bSJamie Iles #define MACB_REV_SIZE 16 463f75ba50bSJamie Iles 464757a03c6SJamie Iles /* Bitfields in DCFG1. */ 465581df9e1SNicolas Ferre #define GEM_IRQCOR_OFFSET 23 466581df9e1SNicolas Ferre #define GEM_IRQCOR_SIZE 1 467757a03c6SJamie Iles #define GEM_DBWDEF_OFFSET 25 468757a03c6SJamie Iles #define GEM_DBWDEF_SIZE 3 469757a03c6SJamie Iles 470e175587fSNicolas Ferre /* Bitfields in DCFG2. */ 471e175587fSNicolas Ferre #define GEM_RX_PKT_BUFF_OFFSET 20 472e175587fSNicolas Ferre #define GEM_RX_PKT_BUFF_SIZE 1 473e175587fSNicolas Ferre #define GEM_TX_PKT_BUFF_OFFSET 21 474e175587fSNicolas Ferre #define GEM_TX_PKT_BUFF_SIZE 1 475e175587fSNicolas Ferre 4767b429614SRafal Ozieblo 4777b429614SRafal Ozieblo /* Bitfields in DCFG5. */ 4787b429614SRafal Ozieblo #define GEM_TSU_OFFSET 8 4797b429614SRafal Ozieblo #define GEM_TSU_SIZE 1 4807b429614SRafal Ozieblo 4811629dd4fSRafal Ozieblo /* Bitfields in DCFG6. */ 4821629dd4fSRafal Ozieblo #define GEM_PBUF_LSO_OFFSET 27 4831629dd4fSRafal Ozieblo #define GEM_PBUF_LSO_SIZE 1 484dc97a89eSRafal Ozieblo #define GEM_DAW64_OFFSET 23 485dc97a89eSRafal Ozieblo #define GEM_DAW64_SIZE 1 4861629dd4fSRafal Ozieblo 487ae8223deSRafal Ozieblo /* Bitfields in DCFG8. */ 488ae8223deSRafal Ozieblo #define GEM_T1SCR_OFFSET 24 489ae8223deSRafal Ozieblo #define GEM_T1SCR_SIZE 8 490ae8223deSRafal Ozieblo #define GEM_T2SCR_OFFSET 16 491ae8223deSRafal Ozieblo #define GEM_T2SCR_SIZE 8 492ae8223deSRafal Ozieblo #define GEM_SCR2ETH_OFFSET 8 493ae8223deSRafal Ozieblo #define GEM_SCR2ETH_SIZE 8 494ae8223deSRafal Ozieblo #define GEM_SCR2CMP_OFFSET 0 495ae8223deSRafal Ozieblo #define GEM_SCR2CMP_SIZE 8 496ae8223deSRafal Ozieblo 497404cd086SHarini Katakam /* Bitfields in DCFG10 */ 498404cd086SHarini Katakam #define GEM_TXBD_RDBUFF_OFFSET 12 499404cd086SHarini Katakam #define GEM_TXBD_RDBUFF_SIZE 4 500404cd086SHarini Katakam #define GEM_RXBD_RDBUFF_OFFSET 8 501404cd086SHarini Katakam #define GEM_RXBD_RDBUFF_SIZE 4 502404cd086SHarini Katakam 503c2594d80SAndrei.Pistirica@microchip.com /* Bitfields in TISUBN */ 504c2594d80SAndrei.Pistirica@microchip.com #define GEM_SUBNSINCR_OFFSET 0 5057ad342bcSHarini Katakam #define GEM_SUBNSINCRL_OFFSET 24 5067ad342bcSHarini Katakam #define GEM_SUBNSINCRL_SIZE 8 5077ad342bcSHarini Katakam #define GEM_SUBNSINCRH_OFFSET 0 5087ad342bcSHarini Katakam #define GEM_SUBNSINCRH_SIZE 16 5097ad342bcSHarini Katakam #define GEM_SUBNSINCR_SIZE 24 510c2594d80SAndrei.Pistirica@microchip.com 511c2594d80SAndrei.Pistirica@microchip.com /* Bitfields in TI */ 512c2594d80SAndrei.Pistirica@microchip.com #define GEM_NSINCR_OFFSET 0 513c2594d80SAndrei.Pistirica@microchip.com #define GEM_NSINCR_SIZE 8 514c2594d80SAndrei.Pistirica@microchip.com 515ab91f0a9SRafal Ozieblo /* Bitfields in TSH */ 516ab91f0a9SRafal Ozieblo #define GEM_TSH_OFFSET 0 /* TSU timer value (s). MSB [47:32] of seconds timer count */ 517ab91f0a9SRafal Ozieblo #define GEM_TSH_SIZE 16 518ab91f0a9SRafal Ozieblo 519ab91f0a9SRafal Ozieblo /* Bitfields in TSL */ 520ab91f0a9SRafal Ozieblo #define GEM_TSL_OFFSET 0 /* TSU timer value (s). LSB [31:0] of seconds timer count */ 521ab91f0a9SRafal Ozieblo #define GEM_TSL_SIZE 32 522ab91f0a9SRafal Ozieblo 523ab91f0a9SRafal Ozieblo /* Bitfields in TN */ 524ab91f0a9SRafal Ozieblo #define GEM_TN_OFFSET 0 /* TSU timer value (ns) */ 525ab91f0a9SRafal Ozieblo #define GEM_TN_SIZE 30 526ab91f0a9SRafal Ozieblo 527ab91f0a9SRafal Ozieblo /* Bitfields in TXBDCTRL */ 528ab91f0a9SRafal Ozieblo #define GEM_TXTSMODE_OFFSET 4 /* TX Descriptor Timestamp Insertion mode */ 529ab91f0a9SRafal Ozieblo #define GEM_TXTSMODE_SIZE 2 530ab91f0a9SRafal Ozieblo 531ab91f0a9SRafal Ozieblo /* Bitfields in RXBDCTRL */ 532ab91f0a9SRafal Ozieblo #define GEM_RXTSMODE_OFFSET 4 /* RX Descriptor Timestamp Insertion mode */ 533ab91f0a9SRafal Ozieblo #define GEM_RXTSMODE_SIZE 2 534ab91f0a9SRafal Ozieblo 535ae8223deSRafal Ozieblo /* Bitfields in SCRT2 */ 536ae8223deSRafal Ozieblo #define GEM_QUEUE_OFFSET 0 /* Queue Number */ 537ae8223deSRafal Ozieblo #define GEM_QUEUE_SIZE 4 538ae8223deSRafal Ozieblo #define GEM_VLANPR_OFFSET 4 /* VLAN Priority */ 539ae8223deSRafal Ozieblo #define GEM_VLANPR_SIZE 3 540ae8223deSRafal Ozieblo #define GEM_VLANEN_OFFSET 8 /* VLAN Enable */ 541ae8223deSRafal Ozieblo #define GEM_VLANEN_SIZE 1 542ae8223deSRafal Ozieblo #define GEM_ETHT2IDX_OFFSET 9 /* Index to screener type 2 EtherType register */ 543ae8223deSRafal Ozieblo #define GEM_ETHT2IDX_SIZE 3 544ae8223deSRafal Ozieblo #define GEM_ETHTEN_OFFSET 12 /* EtherType Enable */ 545ae8223deSRafal Ozieblo #define GEM_ETHTEN_SIZE 1 546ae8223deSRafal Ozieblo #define GEM_CMPA_OFFSET 13 /* Compare A - Index to screener type 2 Compare register */ 547ae8223deSRafal Ozieblo #define GEM_CMPA_SIZE 5 548ae8223deSRafal Ozieblo #define GEM_CMPAEN_OFFSET 18 /* Compare A Enable */ 549ae8223deSRafal Ozieblo #define GEM_CMPAEN_SIZE 1 550ae8223deSRafal Ozieblo #define GEM_CMPB_OFFSET 19 /* Compare B - Index to screener type 2 Compare register */ 551ae8223deSRafal Ozieblo #define GEM_CMPB_SIZE 5 552ae8223deSRafal Ozieblo #define GEM_CMPBEN_OFFSET 24 /* Compare B Enable */ 553ae8223deSRafal Ozieblo #define GEM_CMPBEN_SIZE 1 554ae8223deSRafal Ozieblo #define GEM_CMPC_OFFSET 25 /* Compare C - Index to screener type 2 Compare register */ 555ae8223deSRafal Ozieblo #define GEM_CMPC_SIZE 5 556ae8223deSRafal Ozieblo #define GEM_CMPCEN_OFFSET 30 /* Compare C Enable */ 557ae8223deSRafal Ozieblo #define GEM_CMPCEN_SIZE 1 558ae8223deSRafal Ozieblo 559ae8223deSRafal Ozieblo /* Bitfields in ETHT */ 560ae8223deSRafal Ozieblo #define GEM_ETHTCMP_OFFSET 0 /* EtherType compare value */ 561ae8223deSRafal Ozieblo #define GEM_ETHTCMP_SIZE 16 562ae8223deSRafal Ozieblo 563ae8223deSRafal Ozieblo /* Bitfields in T2CMPW0 */ 564ae8223deSRafal Ozieblo #define GEM_T2CMP_OFFSET 16 /* 0xFFFF0000 compare value */ 565ae8223deSRafal Ozieblo #define GEM_T2CMP_SIZE 16 566ae8223deSRafal Ozieblo #define GEM_T2MASK_OFFSET 0 /* 0x0000FFFF compare value or mask */ 567ae8223deSRafal Ozieblo #define GEM_T2MASK_SIZE 16 568ae8223deSRafal Ozieblo 569ae8223deSRafal Ozieblo /* Bitfields in T2CMPW1 */ 570ae8223deSRafal Ozieblo #define GEM_T2DISMSK_OFFSET 9 /* disable mask */ 571ae8223deSRafal Ozieblo #define GEM_T2DISMSK_SIZE 1 572ae8223deSRafal Ozieblo #define GEM_T2CMPOFST_OFFSET 7 /* compare offset */ 573ae8223deSRafal Ozieblo #define GEM_T2CMPOFST_SIZE 2 574ae8223deSRafal Ozieblo #define GEM_T2OFST_OFFSET 0 /* offset value */ 575ae8223deSRafal Ozieblo #define GEM_T2OFST_SIZE 7 576ae8223deSRafal Ozieblo 577ae8223deSRafal Ozieblo /* Offset for screener type 2 compare values (T2CMPOFST). 578ae8223deSRafal Ozieblo * Note the offset is applied after the specified point, 579ae8223deSRafal Ozieblo * e.g. GEM_T2COMPOFST_ETYPE denotes the EtherType field, so an offset 580ae8223deSRafal Ozieblo * of 12 bytes from this would be the source IP address in an IP header 581ae8223deSRafal Ozieblo */ 582ae8223deSRafal Ozieblo #define GEM_T2COMPOFST_SOF 0 583ae8223deSRafal Ozieblo #define GEM_T2COMPOFST_ETYPE 1 584ae8223deSRafal Ozieblo #define GEM_T2COMPOFST_IPHDR 2 585ae8223deSRafal Ozieblo #define GEM_T2COMPOFST_TCPUDP 3 586ae8223deSRafal Ozieblo 587ae8223deSRafal Ozieblo /* offset from EtherType to IP address */ 588ae8223deSRafal Ozieblo #define ETYPE_SRCIP_OFFSET 12 589ae8223deSRafal Ozieblo #define ETYPE_DSTIP_OFFSET 16 590ae8223deSRafal Ozieblo 591ae8223deSRafal Ozieblo /* offset from IP header to port */ 592ae8223deSRafal Ozieblo #define IPHDR_SRCPORT_OFFSET 0 593ae8223deSRafal Ozieblo #define IPHDR_DSTPORT_OFFSET 2 594ae8223deSRafal Ozieblo 595ab91f0a9SRafal Ozieblo /* Transmit DMA buffer descriptor Word 1 */ 596ab91f0a9SRafal Ozieblo #define GEM_DMA_TXVALID_OFFSET 23 /* timestamp has been captured in the Buffer Descriptor */ 597ab91f0a9SRafal Ozieblo #define GEM_DMA_TXVALID_SIZE 1 598ab91f0a9SRafal Ozieblo 599ab91f0a9SRafal Ozieblo /* Receive DMA buffer descriptor Word 0 */ 600ab91f0a9SRafal Ozieblo #define GEM_DMA_RXVALID_OFFSET 2 /* indicates a valid timestamp in the Buffer Descriptor */ 601ab91f0a9SRafal Ozieblo #define GEM_DMA_RXVALID_SIZE 1 602ab91f0a9SRafal Ozieblo 603ab91f0a9SRafal Ozieblo /* DMA buffer descriptor Word 2 (32 bit addressing) or Word 4 (64 bit addressing) */ 604ab91f0a9SRafal Ozieblo #define GEM_DMA_SECL_OFFSET 30 /* Timestamp seconds[1:0] */ 605ab91f0a9SRafal Ozieblo #define GEM_DMA_SECL_SIZE 2 606ab91f0a9SRafal Ozieblo #define GEM_DMA_NSEC_OFFSET 0 /* Timestamp nanosecs [29:0] */ 607ab91f0a9SRafal Ozieblo #define GEM_DMA_NSEC_SIZE 30 608ab91f0a9SRafal Ozieblo 609ab91f0a9SRafal Ozieblo /* DMA buffer descriptor Word 3 (32 bit addressing) or Word 5 (64 bit addressing) */ 610ab91f0a9SRafal Ozieblo 611ab91f0a9SRafal Ozieblo /* New hardware supports 12 bit precision of timestamp in DMA buffer descriptor. 612ab91f0a9SRafal Ozieblo * Old hardware supports only 6 bit precision but it is enough for PTP. 613ab91f0a9SRafal Ozieblo * Less accuracy is used always instead of checking hardware version. 614ab91f0a9SRafal Ozieblo */ 615ab91f0a9SRafal Ozieblo #define GEM_DMA_SECH_OFFSET 0 /* Timestamp seconds[5:2] */ 616ab91f0a9SRafal Ozieblo #define GEM_DMA_SECH_SIZE 4 617ab91f0a9SRafal Ozieblo #define GEM_DMA_SEC_WIDTH (GEM_DMA_SECH_SIZE + GEM_DMA_SECL_SIZE) 618ab91f0a9SRafal Ozieblo #define GEM_DMA_SEC_TOP (1 << GEM_DMA_SEC_WIDTH) 619ab91f0a9SRafal Ozieblo #define GEM_DMA_SEC_MASK (GEM_DMA_SEC_TOP - 1) 620ab91f0a9SRafal Ozieblo 621c2594d80SAndrei.Pistirica@microchip.com /* Bitfields in ADJ */ 622c2594d80SAndrei.Pistirica@microchip.com #define GEM_ADDSUB_OFFSET 31 623c2594d80SAndrei.Pistirica@microchip.com #define GEM_ADDSUB_SIZE 1 6249f2f381fSJeff Kirsher /* Constants for CLK */ 6259f2f381fSJeff Kirsher #define MACB_CLK_DIV8 0 6269f2f381fSJeff Kirsher #define MACB_CLK_DIV16 1 6279f2f381fSJeff Kirsher #define MACB_CLK_DIV32 2 6289f2f381fSJeff Kirsher #define MACB_CLK_DIV64 3 6299f2f381fSJeff Kirsher 63070c9f3d4SJamie Iles /* GEM specific constants for CLK. */ 63170c9f3d4SJamie Iles #define GEM_CLK_DIV8 0 63270c9f3d4SJamie Iles #define GEM_CLK_DIV16 1 63370c9f3d4SJamie Iles #define GEM_CLK_DIV32 2 63470c9f3d4SJamie Iles #define GEM_CLK_DIV48 3 63570c9f3d4SJamie Iles #define GEM_CLK_DIV64 4 63670c9f3d4SJamie Iles #define GEM_CLK_DIV96 5 63770c9f3d4SJamie Iles 6389f2f381fSJeff Kirsher /* Constants for MAN register */ 63943ad352dSMilind Parab #define MACB_MAN_C22_SOF 1 64043ad352dSMilind Parab #define MACB_MAN_C22_WRITE 1 64143ad352dSMilind Parab #define MACB_MAN_C22_READ 2 64243ad352dSMilind Parab #define MACB_MAN_C22_CODE 2 64343ad352dSMilind Parab 64443ad352dSMilind Parab #define MACB_MAN_C45_SOF 0 64543ad352dSMilind Parab #define MACB_MAN_C45_ADDR 0 64643ad352dSMilind Parab #define MACB_MAN_C45_WRITE 1 64743ad352dSMilind Parab #define MACB_MAN_C45_POST_READ_INCR 2 64843ad352dSMilind Parab #define MACB_MAN_C45_READ 3 64943ad352dSMilind Parab #define MACB_MAN_C45_CODE 2 6509f2f381fSJeff Kirsher 651581df9e1SNicolas Ferre /* Capability mask bits */ 652e175587fSNicolas Ferre #define MACB_CAPS_ISR_CLEAR_ON_WRITE 0x00000001 653a8487489SBoris BREZILLON #define MACB_CAPS_USRIO_HAS_CLKEN 0x00000002 6546bdaa5e9SNicolas Ferre #define MACB_CAPS_USRIO_DEFAULT_IS_MII_GMII 0x00000004 655222ca8e0SNathan Sullivan #define MACB_CAPS_NO_GIGABIT_HALF 0x00000008 656ce721a70SNeil Armstrong #define MACB_CAPS_USRIO_DISABLED 0x00000010 657c5181895SHarini Katakam #define MACB_CAPS_JUMBO 0x00000020 658c2594d80SAndrei.Pistirica@microchip.com #define MACB_CAPS_GEM_HAS_PTP 0x00000040 659404cd086SHarini Katakam #define MACB_CAPS_BD_RD_PREFETCH 0x00000080 660e501070eSHarini Katakam #define MACB_CAPS_NEEDS_RSTONUBR 0x00000100 661ac2fcfa9SAlexandre Belloni #define MACB_CAPS_MACB_IS_EMAC 0x08000000 662e175587fSNicolas Ferre #define MACB_CAPS_FIFO_MODE 0x10000000 663e175587fSNicolas Ferre #define MACB_CAPS_GIGABIT_MODE_AVAILABLE 0x20000000 664a4c35ed3SCyrille Pitchen #define MACB_CAPS_SG_DISABLED 0x40000000 665e175587fSNicolas Ferre #define MACB_CAPS_MACB_IS_GEM 0x80000000 666581df9e1SNicolas Ferre 6671629dd4fSRafal Ozieblo /* LSO settings */ 6681629dd4fSRafal Ozieblo #define MACB_LSO_UFO_ENABLE 0x01 6691629dd4fSRafal Ozieblo #define MACB_LSO_TSO_ENABLE 0x02 6701629dd4fSRafal Ozieblo 6719f2f381fSJeff Kirsher /* Bit manipulation macros */ 6729f2f381fSJeff Kirsher #define MACB_BIT(name) \ 6739f2f381fSJeff Kirsher (1 << MACB_##name##_OFFSET) 6749f2f381fSJeff Kirsher #define MACB_BF(name,value) \ 6759f2f381fSJeff Kirsher (((value) & ((1 << MACB_##name##_SIZE) - 1)) \ 6769f2f381fSJeff Kirsher << MACB_##name##_OFFSET) 6779f2f381fSJeff Kirsher #define MACB_BFEXT(name,value)\ 6789f2f381fSJeff Kirsher (((value) >> MACB_##name##_OFFSET) \ 6799f2f381fSJeff Kirsher & ((1 << MACB_##name##_SIZE) - 1)) 6809f2f381fSJeff Kirsher #define MACB_BFINS(name,value,old) \ 6819f2f381fSJeff Kirsher (((old) & ~(((1 << MACB_##name##_SIZE) - 1) \ 6829f2f381fSJeff Kirsher << MACB_##name##_OFFSET)) \ 6839f2f381fSJeff Kirsher | MACB_BF(name,value)) 6849f2f381fSJeff Kirsher 685f75ba50bSJamie Iles #define GEM_BIT(name) \ 686f75ba50bSJamie Iles (1 << GEM_##name##_OFFSET) 687f75ba50bSJamie Iles #define GEM_BF(name, value) \ 688f75ba50bSJamie Iles (((value) & ((1 << GEM_##name##_SIZE) - 1)) \ 689f75ba50bSJamie Iles << GEM_##name##_OFFSET) 690f75ba50bSJamie Iles #define GEM_BFEXT(name, value)\ 691f75ba50bSJamie Iles (((value) >> GEM_##name##_OFFSET) \ 692f75ba50bSJamie Iles & ((1 << GEM_##name##_SIZE) - 1)) 693f75ba50bSJamie Iles #define GEM_BFINS(name, value, old) \ 694f75ba50bSJamie Iles (((old) & ~(((1 << GEM_##name##_SIZE) - 1) \ 695f75ba50bSJamie Iles << GEM_##name##_OFFSET)) \ 696f75ba50bSJamie Iles | GEM_BF(name, value)) 697f75ba50bSJamie Iles 6989f2f381fSJeff Kirsher /* Register access macros */ 6997a6e0706SDavid S. Miller #define macb_readl(port, reg) (port)->macb_reg_readl((port), MACB_##reg) 7007a6e0706SDavid S. Miller #define macb_writel(port, reg, value) (port)->macb_reg_writel((port), MACB_##reg, (value)) 7017a6e0706SDavid S. Miller #define gem_readl(port, reg) (port)->macb_reg_readl((port), GEM_##reg) 7027a6e0706SDavid S. Miller #define gem_writel(port, reg, value) (port)->macb_reg_writel((port), GEM_##reg, (value)) 7037a6e0706SDavid S. Miller #define queue_readl(queue, reg) (queue)->bp->macb_reg_readl((queue)->bp, (queue)->reg) 7047a6e0706SDavid S. Miller #define queue_writel(queue, reg, value) (queue)->bp->macb_reg_writel((queue)->bp, (queue)->reg, (value)) 705ae8223deSRafal Ozieblo #define gem_readl_n(port, reg, idx) (port)->macb_reg_readl((port), GEM_##reg + idx * 4) 706ae8223deSRafal Ozieblo #define gem_writel_n(port, reg, idx, value) (port)->macb_reg_writel((port), GEM_##reg + idx * 4, (value)) 707f75ba50bSJamie Iles 708ab91f0a9SRafal Ozieblo #define PTP_TS_BUFFER_SIZE 128 /* must be power of 2 */ 709ab91f0a9SRafal Ozieblo 7106f79eed8SXander Huff /* Conditional GEM/MACB macros. These perform the operation to the correct 711f75ba50bSJamie Iles * register dependent on whether the device is a GEM or a MACB. For registers 712f75ba50bSJamie Iles * and bitfields that are common across both devices, use macb_{read,write}l 713f75ba50bSJamie Iles * to avoid the cost of the conditional. 714f75ba50bSJamie Iles */ 715f75ba50bSJamie Iles #define macb_or_gem_writel(__bp, __reg, __value) \ 716f75ba50bSJamie Iles ({ \ 717f75ba50bSJamie Iles if (macb_is_gem((__bp))) \ 718f75ba50bSJamie Iles gem_writel((__bp), __reg, __value); \ 719f75ba50bSJamie Iles else \ 720f75ba50bSJamie Iles macb_writel((__bp), __reg, __value); \ 721f75ba50bSJamie Iles }) 722f75ba50bSJamie Iles 723f75ba50bSJamie Iles #define macb_or_gem_readl(__bp, __reg) \ 724f75ba50bSJamie Iles ({ \ 725f75ba50bSJamie Iles u32 __v; \ 726f75ba50bSJamie Iles if (macb_is_gem((__bp))) \ 727f75ba50bSJamie Iles __v = gem_readl((__bp), __reg); \ 728f75ba50bSJamie Iles else \ 729f75ba50bSJamie Iles __v = macb_readl((__bp), __reg); \ 730f75ba50bSJamie Iles __v; \ 731f75ba50bSJamie Iles }) 7329f2f381fSJeff Kirsher 7338beb79b7SHarini Katakam #define MACB_READ_NSR(bp) macb_readl(bp, NSR) 7348beb79b7SHarini Katakam 7356f79eed8SXander Huff /* struct macb_dma_desc - Hardware DMA descriptor 73655054a16SHavard Skinnemoen * @addr: DMA address of data buffer 73755054a16SHavard Skinnemoen * @ctrl: Control and status bits 73855054a16SHavard Skinnemoen */ 73955054a16SHavard Skinnemoen struct macb_dma_desc { 7409f2f381fSJeff Kirsher u32 addr; 7419f2f381fSJeff Kirsher u32 ctrl; 742dc97a89eSRafal Ozieblo }; 743dc97a89eSRafal Ozieblo 7447b429614SRafal Ozieblo #ifdef MACB_EXT_DESC 7457b429614SRafal Ozieblo #define HW_DMA_CAP_32B 0 7467b429614SRafal Ozieblo #define HW_DMA_CAP_64B (1 << 0) 7477b429614SRafal Ozieblo #define HW_DMA_CAP_PTP (1 << 1) 7487b429614SRafal Ozieblo #define HW_DMA_CAP_64B_PTP (HW_DMA_CAP_64B | HW_DMA_CAP_PTP) 749dc97a89eSRafal Ozieblo 750dc97a89eSRafal Ozieblo struct macb_dma_desc_64 { 751fff8019aSHarini Katakam u32 addrh; 752fff8019aSHarini Katakam u32 resvd; 7539f2f381fSJeff Kirsher }; 7547b429614SRafal Ozieblo 7557b429614SRafal Ozieblo struct macb_dma_desc_ptp { 7567b429614SRafal Ozieblo u32 ts_1; 7577b429614SRafal Ozieblo u32 ts_2; 7587b429614SRafal Ozieblo }; 759ab91f0a9SRafal Ozieblo 760ab91f0a9SRafal Ozieblo struct gem_tx_ts { 761ab91f0a9SRafal Ozieblo struct sk_buff *skb; 762ab91f0a9SRafal Ozieblo struct macb_dma_desc_ptp desc_ptp; 763ab91f0a9SRafal Ozieblo }; 764dc97a89eSRafal Ozieblo #endif 7659f2f381fSJeff Kirsher 7669f2f381fSJeff Kirsher /* DMA descriptor bitfields */ 7679f2f381fSJeff Kirsher #define MACB_RX_USED_OFFSET 0 7689f2f381fSJeff Kirsher #define MACB_RX_USED_SIZE 1 7699f2f381fSJeff Kirsher #define MACB_RX_WRAP_OFFSET 1 7709f2f381fSJeff Kirsher #define MACB_RX_WRAP_SIZE 1 7719f2f381fSJeff Kirsher #define MACB_RX_WADDR_OFFSET 2 7729f2f381fSJeff Kirsher #define MACB_RX_WADDR_SIZE 30 7739f2f381fSJeff Kirsher 7749f2f381fSJeff Kirsher #define MACB_RX_FRMLEN_OFFSET 0 7759f2f381fSJeff Kirsher #define MACB_RX_FRMLEN_SIZE 12 7769f2f381fSJeff Kirsher #define MACB_RX_OFFSET_OFFSET 12 7779f2f381fSJeff Kirsher #define MACB_RX_OFFSET_SIZE 2 7789f2f381fSJeff Kirsher #define MACB_RX_SOF_OFFSET 14 7799f2f381fSJeff Kirsher #define MACB_RX_SOF_SIZE 1 7809f2f381fSJeff Kirsher #define MACB_RX_EOF_OFFSET 15 7819f2f381fSJeff Kirsher #define MACB_RX_EOF_SIZE 1 7829f2f381fSJeff Kirsher #define MACB_RX_CFI_OFFSET 16 7839f2f381fSJeff Kirsher #define MACB_RX_CFI_SIZE 1 7849f2f381fSJeff Kirsher #define MACB_RX_VLAN_PRI_OFFSET 17 7859f2f381fSJeff Kirsher #define MACB_RX_VLAN_PRI_SIZE 3 7869f2f381fSJeff Kirsher #define MACB_RX_PRI_TAG_OFFSET 20 7879f2f381fSJeff Kirsher #define MACB_RX_PRI_TAG_SIZE 1 7889f2f381fSJeff Kirsher #define MACB_RX_VLAN_TAG_OFFSET 21 7899f2f381fSJeff Kirsher #define MACB_RX_VLAN_TAG_SIZE 1 7909f2f381fSJeff Kirsher #define MACB_RX_TYPEID_MATCH_OFFSET 22 7919f2f381fSJeff Kirsher #define MACB_RX_TYPEID_MATCH_SIZE 1 7929f2f381fSJeff Kirsher #define MACB_RX_SA4_MATCH_OFFSET 23 7939f2f381fSJeff Kirsher #define MACB_RX_SA4_MATCH_SIZE 1 7949f2f381fSJeff Kirsher #define MACB_RX_SA3_MATCH_OFFSET 24 7959f2f381fSJeff Kirsher #define MACB_RX_SA3_MATCH_SIZE 1 7969f2f381fSJeff Kirsher #define MACB_RX_SA2_MATCH_OFFSET 25 7979f2f381fSJeff Kirsher #define MACB_RX_SA2_MATCH_SIZE 1 7989f2f381fSJeff Kirsher #define MACB_RX_SA1_MATCH_OFFSET 26 7999f2f381fSJeff Kirsher #define MACB_RX_SA1_MATCH_SIZE 1 8009f2f381fSJeff Kirsher #define MACB_RX_EXT_MATCH_OFFSET 28 8019f2f381fSJeff Kirsher #define MACB_RX_EXT_MATCH_SIZE 1 8029f2f381fSJeff Kirsher #define MACB_RX_UHASH_MATCH_OFFSET 29 8039f2f381fSJeff Kirsher #define MACB_RX_UHASH_MATCH_SIZE 1 8049f2f381fSJeff Kirsher #define MACB_RX_MHASH_MATCH_OFFSET 30 8059f2f381fSJeff Kirsher #define MACB_RX_MHASH_MATCH_SIZE 1 8069f2f381fSJeff Kirsher #define MACB_RX_BROADCAST_OFFSET 31 8079f2f381fSJeff Kirsher #define MACB_RX_BROADCAST_SIZE 1 8089f2f381fSJeff Kirsher 80998b5a0f4SHarini Katakam #define MACB_RX_FRMLEN_MASK 0xFFF 81098b5a0f4SHarini Katakam #define MACB_RX_JFRMLEN_MASK 0x3FFF 81198b5a0f4SHarini Katakam 812924ec53cSCyrille Pitchen /* RX checksum offload disabled: bit 24 clear in NCFGR */ 813924ec53cSCyrille Pitchen #define GEM_RX_TYPEID_MATCH_OFFSET 22 814924ec53cSCyrille Pitchen #define GEM_RX_TYPEID_MATCH_SIZE 2 815924ec53cSCyrille Pitchen 816924ec53cSCyrille Pitchen /* RX checksum offload enabled: bit 24 set in NCFGR */ 817924ec53cSCyrille Pitchen #define GEM_RX_CSUM_OFFSET 22 818924ec53cSCyrille Pitchen #define GEM_RX_CSUM_SIZE 2 819924ec53cSCyrille Pitchen 8209f2f381fSJeff Kirsher #define MACB_TX_FRMLEN_OFFSET 0 8219f2f381fSJeff Kirsher #define MACB_TX_FRMLEN_SIZE 11 8229f2f381fSJeff Kirsher #define MACB_TX_LAST_OFFSET 15 8239f2f381fSJeff Kirsher #define MACB_TX_LAST_SIZE 1 8249f2f381fSJeff Kirsher #define MACB_TX_NOCRC_OFFSET 16 8259f2f381fSJeff Kirsher #define MACB_TX_NOCRC_SIZE 1 8261629dd4fSRafal Ozieblo #define MACB_MSS_MFS_OFFSET 16 8271629dd4fSRafal Ozieblo #define MACB_MSS_MFS_SIZE 14 8281629dd4fSRafal Ozieblo #define MACB_TX_LSO_OFFSET 17 8291629dd4fSRafal Ozieblo #define MACB_TX_LSO_SIZE 2 8301629dd4fSRafal Ozieblo #define MACB_TX_TCP_SEQ_SRC_OFFSET 19 8311629dd4fSRafal Ozieblo #define MACB_TX_TCP_SEQ_SRC_SIZE 1 8329f2f381fSJeff Kirsher #define MACB_TX_BUF_EXHAUSTED_OFFSET 27 8339f2f381fSJeff Kirsher #define MACB_TX_BUF_EXHAUSTED_SIZE 1 8349f2f381fSJeff Kirsher #define MACB_TX_UNDERRUN_OFFSET 28 8359f2f381fSJeff Kirsher #define MACB_TX_UNDERRUN_SIZE 1 8369f2f381fSJeff Kirsher #define MACB_TX_ERROR_OFFSET 29 8379f2f381fSJeff Kirsher #define MACB_TX_ERROR_SIZE 1 8389f2f381fSJeff Kirsher #define MACB_TX_WRAP_OFFSET 30 8399f2f381fSJeff Kirsher #define MACB_TX_WRAP_SIZE 1 8409f2f381fSJeff Kirsher #define MACB_TX_USED_OFFSET 31 8419f2f381fSJeff Kirsher #define MACB_TX_USED_SIZE 1 8429f2f381fSJeff Kirsher 843a4c35ed3SCyrille Pitchen #define GEM_TX_FRMLEN_OFFSET 0 844a4c35ed3SCyrille Pitchen #define GEM_TX_FRMLEN_SIZE 14 845a4c35ed3SCyrille Pitchen 846924ec53cSCyrille Pitchen /* Buffer descriptor constants */ 847924ec53cSCyrille Pitchen #define GEM_RX_CSUM_NONE 0 848924ec53cSCyrille Pitchen #define GEM_RX_CSUM_IP_ONLY 1 849924ec53cSCyrille Pitchen #define GEM_RX_CSUM_IP_TCP 2 850924ec53cSCyrille Pitchen #define GEM_RX_CSUM_IP_UDP 3 851924ec53cSCyrille Pitchen 852924ec53cSCyrille Pitchen /* limit RX checksum offload to TCP and UDP packets */ 853924ec53cSCyrille Pitchen #define GEM_RX_CSUM_CHECKED_MASK 2 854924ec53cSCyrille Pitchen 855a8ee4dc1SHarini Katakam /* Scaled PPM fraction */ 856a8ee4dc1SHarini Katakam #define PPM_FRACTION 16 857a8ee4dc1SHarini Katakam 8586f79eed8SXander Huff /* struct macb_tx_skb - data about an skb which is being transmitted 859a4c35ed3SCyrille Pitchen * @skb: skb currently being transmitted, only set for the last buffer 860a4c35ed3SCyrille Pitchen * of the frame 861a4c35ed3SCyrille Pitchen * @mapping: DMA address of the skb's fragment buffer 862a4c35ed3SCyrille Pitchen * @size: size of the DMA mapped buffer 863a4c35ed3SCyrille Pitchen * @mapped_as_page: true when buffer was mapped with skb_frag_dma_map(), 864a4c35ed3SCyrille Pitchen * false when buffer was mapped with dma_map_single() 86555054a16SHavard Skinnemoen */ 86655054a16SHavard Skinnemoen struct macb_tx_skb { 8679f2f381fSJeff Kirsher struct sk_buff *skb; 8689f2f381fSJeff Kirsher dma_addr_t mapping; 869a4c35ed3SCyrille Pitchen size_t size; 870a4c35ed3SCyrille Pitchen bool mapped_as_page; 8719f2f381fSJeff Kirsher }; 8729f2f381fSJeff Kirsher 8736f79eed8SXander Huff /* Hardware-collected statistics. Used when updating the network 8749f2f381fSJeff Kirsher * device stats by a periodic timer. 8759f2f381fSJeff Kirsher */ 8769f2f381fSJeff Kirsher struct macb_stats { 8779f2f381fSJeff Kirsher u32 rx_pause_frames; 8789f2f381fSJeff Kirsher u32 tx_ok; 8799f2f381fSJeff Kirsher u32 tx_single_cols; 8809f2f381fSJeff Kirsher u32 tx_multiple_cols; 8819f2f381fSJeff Kirsher u32 rx_ok; 8829f2f381fSJeff Kirsher u32 rx_fcs_errors; 8839f2f381fSJeff Kirsher u32 rx_align_errors; 8849f2f381fSJeff Kirsher u32 tx_deferred; 8859f2f381fSJeff Kirsher u32 tx_late_cols; 8869f2f381fSJeff Kirsher u32 tx_excessive_cols; 8879f2f381fSJeff Kirsher u32 tx_underruns; 8889f2f381fSJeff Kirsher u32 tx_carrier_errors; 8899f2f381fSJeff Kirsher u32 rx_resource_errors; 8909f2f381fSJeff Kirsher u32 rx_overruns; 8919f2f381fSJeff Kirsher u32 rx_symbol_errors; 8929f2f381fSJeff Kirsher u32 rx_oversize_pkts; 8939f2f381fSJeff Kirsher u32 rx_jabbers; 8949f2f381fSJeff Kirsher u32 rx_undersize_pkts; 8959f2f381fSJeff Kirsher u32 sqe_test_errors; 8969f2f381fSJeff Kirsher u32 rx_length_mismatch; 8979f2f381fSJeff Kirsher u32 tx_pause_frames; 8989f2f381fSJeff Kirsher }; 8999f2f381fSJeff Kirsher 900a494ed8eSJamie Iles struct gem_stats { 901a494ed8eSJamie Iles u32 tx_octets_31_0; 902a494ed8eSJamie Iles u32 tx_octets_47_32; 903a494ed8eSJamie Iles u32 tx_frames; 904a494ed8eSJamie Iles u32 tx_broadcast_frames; 905a494ed8eSJamie Iles u32 tx_multicast_frames; 906a494ed8eSJamie Iles u32 tx_pause_frames; 907a494ed8eSJamie Iles u32 tx_64_byte_frames; 908a494ed8eSJamie Iles u32 tx_65_127_byte_frames; 909a494ed8eSJamie Iles u32 tx_128_255_byte_frames; 910a494ed8eSJamie Iles u32 tx_256_511_byte_frames; 911a494ed8eSJamie Iles u32 tx_512_1023_byte_frames; 912a494ed8eSJamie Iles u32 tx_1024_1518_byte_frames; 913a494ed8eSJamie Iles u32 tx_greater_than_1518_byte_frames; 914a494ed8eSJamie Iles u32 tx_underrun; 915a494ed8eSJamie Iles u32 tx_single_collision_frames; 916a494ed8eSJamie Iles u32 tx_multiple_collision_frames; 917a494ed8eSJamie Iles u32 tx_excessive_collisions; 918a494ed8eSJamie Iles u32 tx_late_collisions; 919a494ed8eSJamie Iles u32 tx_deferred_frames; 920a494ed8eSJamie Iles u32 tx_carrier_sense_errors; 921a494ed8eSJamie Iles u32 rx_octets_31_0; 922a494ed8eSJamie Iles u32 rx_octets_47_32; 923a494ed8eSJamie Iles u32 rx_frames; 924a494ed8eSJamie Iles u32 rx_broadcast_frames; 925a494ed8eSJamie Iles u32 rx_multicast_frames; 926a494ed8eSJamie Iles u32 rx_pause_frames; 927a494ed8eSJamie Iles u32 rx_64_byte_frames; 928a494ed8eSJamie Iles u32 rx_65_127_byte_frames; 929a494ed8eSJamie Iles u32 rx_128_255_byte_frames; 930a494ed8eSJamie Iles u32 rx_256_511_byte_frames; 931a494ed8eSJamie Iles u32 rx_512_1023_byte_frames; 932a494ed8eSJamie Iles u32 rx_1024_1518_byte_frames; 933a494ed8eSJamie Iles u32 rx_greater_than_1518_byte_frames; 934a494ed8eSJamie Iles u32 rx_undersized_frames; 935a494ed8eSJamie Iles u32 rx_oversize_frames; 936a494ed8eSJamie Iles u32 rx_jabbers; 937a494ed8eSJamie Iles u32 rx_frame_check_sequence_errors; 938a494ed8eSJamie Iles u32 rx_length_field_frame_errors; 939a494ed8eSJamie Iles u32 rx_symbol_errors; 940a494ed8eSJamie Iles u32 rx_alignment_errors; 941a494ed8eSJamie Iles u32 rx_resource_errors; 942a494ed8eSJamie Iles u32 rx_overruns; 943a494ed8eSJamie Iles u32 rx_ip_header_checksum_errors; 944a494ed8eSJamie Iles u32 rx_tcp_checksum_errors; 945a494ed8eSJamie Iles u32 rx_udp_checksum_errors; 946a494ed8eSJamie Iles }; 947a494ed8eSJamie Iles 9483ff13f1cSXander Huff /* Describes the name and offset of an individual statistic register, as 9493ff13f1cSXander Huff * returned by `ethtool -S`. Also describes which net_device_stats statistics 9503ff13f1cSXander Huff * this register should contribute to. 9513ff13f1cSXander Huff */ 9523ff13f1cSXander Huff struct gem_statistic { 9533ff13f1cSXander Huff char stat_string[ETH_GSTRING_LEN]; 9543ff13f1cSXander Huff int offset; 9553ff13f1cSXander Huff u32 stat_bits; 9563ff13f1cSXander Huff }; 9573ff13f1cSXander Huff 9583ff13f1cSXander Huff /* Bitfield defs for net_device_stat statistics */ 9593ff13f1cSXander Huff #define GEM_NDS_RXERR_OFFSET 0 9603ff13f1cSXander Huff #define GEM_NDS_RXLENERR_OFFSET 1 9613ff13f1cSXander Huff #define GEM_NDS_RXOVERERR_OFFSET 2 9623ff13f1cSXander Huff #define GEM_NDS_RXCRCERR_OFFSET 3 9633ff13f1cSXander Huff #define GEM_NDS_RXFRAMEERR_OFFSET 4 9643ff13f1cSXander Huff #define GEM_NDS_RXFIFOERR_OFFSET 5 9653ff13f1cSXander Huff #define GEM_NDS_TXERR_OFFSET 6 9663ff13f1cSXander Huff #define GEM_NDS_TXABORTEDERR_OFFSET 7 9673ff13f1cSXander Huff #define GEM_NDS_TXCARRIERERR_OFFSET 8 9683ff13f1cSXander Huff #define GEM_NDS_TXFIFOERR_OFFSET 9 9693ff13f1cSXander Huff #define GEM_NDS_COLLISIONS_OFFSET 10 9703ff13f1cSXander Huff 9713ff13f1cSXander Huff #define GEM_STAT_TITLE(name, title) GEM_STAT_TITLE_BITS(name, title, 0) 9723ff13f1cSXander Huff #define GEM_STAT_TITLE_BITS(name, title, bits) { \ 9733ff13f1cSXander Huff .stat_string = title, \ 9743ff13f1cSXander Huff .offset = GEM_##name, \ 9753ff13f1cSXander Huff .stat_bits = bits \ 9763ff13f1cSXander Huff } 9773ff13f1cSXander Huff 9783ff13f1cSXander Huff /* list of gem statistic registers. The names MUST match the 9793ff13f1cSXander Huff * corresponding GEM_* definitions. 9803ff13f1cSXander Huff */ 9813ff13f1cSXander Huff static const struct gem_statistic gem_statistics[] = { 9823ff13f1cSXander Huff GEM_STAT_TITLE(OCTTXL, "tx_octets"), /* OCTTXH combined with OCTTXL */ 9833ff13f1cSXander Huff GEM_STAT_TITLE(TXCNT, "tx_frames"), 9843ff13f1cSXander Huff GEM_STAT_TITLE(TXBCCNT, "tx_broadcast_frames"), 9853ff13f1cSXander Huff GEM_STAT_TITLE(TXMCCNT, "tx_multicast_frames"), 9863ff13f1cSXander Huff GEM_STAT_TITLE(TXPAUSECNT, "tx_pause_frames"), 9873ff13f1cSXander Huff GEM_STAT_TITLE(TX64CNT, "tx_64_byte_frames"), 9883ff13f1cSXander Huff GEM_STAT_TITLE(TX65CNT, "tx_65_127_byte_frames"), 9893ff13f1cSXander Huff GEM_STAT_TITLE(TX128CNT, "tx_128_255_byte_frames"), 9903ff13f1cSXander Huff GEM_STAT_TITLE(TX256CNT, "tx_256_511_byte_frames"), 9913ff13f1cSXander Huff GEM_STAT_TITLE(TX512CNT, "tx_512_1023_byte_frames"), 9923ff13f1cSXander Huff GEM_STAT_TITLE(TX1024CNT, "tx_1024_1518_byte_frames"), 9933ff13f1cSXander Huff GEM_STAT_TITLE(TX1519CNT, "tx_greater_than_1518_byte_frames"), 9943ff13f1cSXander Huff GEM_STAT_TITLE_BITS(TXURUNCNT, "tx_underrun", 9953ff13f1cSXander Huff GEM_BIT(NDS_TXERR)|GEM_BIT(NDS_TXFIFOERR)), 9963ff13f1cSXander Huff GEM_STAT_TITLE_BITS(SNGLCOLLCNT, "tx_single_collision_frames", 9973ff13f1cSXander Huff GEM_BIT(NDS_TXERR)|GEM_BIT(NDS_COLLISIONS)), 9983ff13f1cSXander Huff GEM_STAT_TITLE_BITS(MULTICOLLCNT, "tx_multiple_collision_frames", 9993ff13f1cSXander Huff GEM_BIT(NDS_TXERR)|GEM_BIT(NDS_COLLISIONS)), 10003ff13f1cSXander Huff GEM_STAT_TITLE_BITS(EXCESSCOLLCNT, "tx_excessive_collisions", 10013ff13f1cSXander Huff GEM_BIT(NDS_TXERR)| 10023ff13f1cSXander Huff GEM_BIT(NDS_TXABORTEDERR)| 10033ff13f1cSXander Huff GEM_BIT(NDS_COLLISIONS)), 10043ff13f1cSXander Huff GEM_STAT_TITLE_BITS(LATECOLLCNT, "tx_late_collisions", 10053ff13f1cSXander Huff GEM_BIT(NDS_TXERR)|GEM_BIT(NDS_COLLISIONS)), 10063ff13f1cSXander Huff GEM_STAT_TITLE(TXDEFERCNT, "tx_deferred_frames"), 10073ff13f1cSXander Huff GEM_STAT_TITLE_BITS(TXCSENSECNT, "tx_carrier_sense_errors", 10083ff13f1cSXander Huff GEM_BIT(NDS_TXERR)|GEM_BIT(NDS_COLLISIONS)), 10093ff13f1cSXander Huff GEM_STAT_TITLE(OCTRXL, "rx_octets"), /* OCTRXH combined with OCTRXL */ 10103ff13f1cSXander Huff GEM_STAT_TITLE(RXCNT, "rx_frames"), 10113ff13f1cSXander Huff GEM_STAT_TITLE(RXBROADCNT, "rx_broadcast_frames"), 10123ff13f1cSXander Huff GEM_STAT_TITLE(RXMULTICNT, "rx_multicast_frames"), 10133ff13f1cSXander Huff GEM_STAT_TITLE(RXPAUSECNT, "rx_pause_frames"), 10143ff13f1cSXander Huff GEM_STAT_TITLE(RX64CNT, "rx_64_byte_frames"), 10153ff13f1cSXander Huff GEM_STAT_TITLE(RX65CNT, "rx_65_127_byte_frames"), 10163ff13f1cSXander Huff GEM_STAT_TITLE(RX128CNT, "rx_128_255_byte_frames"), 10173ff13f1cSXander Huff GEM_STAT_TITLE(RX256CNT, "rx_256_511_byte_frames"), 10183ff13f1cSXander Huff GEM_STAT_TITLE(RX512CNT, "rx_512_1023_byte_frames"), 10193ff13f1cSXander Huff GEM_STAT_TITLE(RX1024CNT, "rx_1024_1518_byte_frames"), 10203ff13f1cSXander Huff GEM_STAT_TITLE(RX1519CNT, "rx_greater_than_1518_byte_frames"), 10213ff13f1cSXander Huff GEM_STAT_TITLE_BITS(RXUNDRCNT, "rx_undersized_frames", 10223ff13f1cSXander Huff GEM_BIT(NDS_RXERR)|GEM_BIT(NDS_RXLENERR)), 10233ff13f1cSXander Huff GEM_STAT_TITLE_BITS(RXOVRCNT, "rx_oversize_frames", 10243ff13f1cSXander Huff GEM_BIT(NDS_RXERR)|GEM_BIT(NDS_RXLENERR)), 10253ff13f1cSXander Huff GEM_STAT_TITLE_BITS(RXJABCNT, "rx_jabbers", 10263ff13f1cSXander Huff GEM_BIT(NDS_RXERR)|GEM_BIT(NDS_RXLENERR)), 10273ff13f1cSXander Huff GEM_STAT_TITLE_BITS(RXFCSCNT, "rx_frame_check_sequence_errors", 10283ff13f1cSXander Huff GEM_BIT(NDS_RXERR)|GEM_BIT(NDS_RXCRCERR)), 10293ff13f1cSXander Huff GEM_STAT_TITLE_BITS(RXLENGTHCNT, "rx_length_field_frame_errors", 10303ff13f1cSXander Huff GEM_BIT(NDS_RXERR)), 10313ff13f1cSXander Huff GEM_STAT_TITLE_BITS(RXSYMBCNT, "rx_symbol_errors", 10323ff13f1cSXander Huff GEM_BIT(NDS_RXERR)|GEM_BIT(NDS_RXFRAMEERR)), 10333ff13f1cSXander Huff GEM_STAT_TITLE_BITS(RXALIGNCNT, "rx_alignment_errors", 10343ff13f1cSXander Huff GEM_BIT(NDS_RXERR)|GEM_BIT(NDS_RXOVERERR)), 10353ff13f1cSXander Huff GEM_STAT_TITLE_BITS(RXRESERRCNT, "rx_resource_errors", 10363ff13f1cSXander Huff GEM_BIT(NDS_RXERR)|GEM_BIT(NDS_RXOVERERR)), 10373ff13f1cSXander Huff GEM_STAT_TITLE_BITS(RXORCNT, "rx_overruns", 10383ff13f1cSXander Huff GEM_BIT(NDS_RXERR)|GEM_BIT(NDS_RXFIFOERR)), 10393ff13f1cSXander Huff GEM_STAT_TITLE_BITS(RXIPCCNT, "rx_ip_header_checksum_errors", 10403ff13f1cSXander Huff GEM_BIT(NDS_RXERR)), 10413ff13f1cSXander Huff GEM_STAT_TITLE_BITS(RXTCPCCNT, "rx_tcp_checksum_errors", 10423ff13f1cSXander Huff GEM_BIT(NDS_RXERR)), 10433ff13f1cSXander Huff GEM_STAT_TITLE_BITS(RXUDPCCNT, "rx_udp_checksum_errors", 10443ff13f1cSXander Huff GEM_BIT(NDS_RXERR)), 10453ff13f1cSXander Huff }; 10463ff13f1cSXander Huff 10473ff13f1cSXander Huff #define GEM_STATS_LEN ARRAY_SIZE(gem_statistics) 10483ff13f1cSXander Huff 1049512286bbSRafal Ozieblo #define QUEUE_STAT_TITLE(title) { \ 1050512286bbSRafal Ozieblo .stat_string = title, \ 1051512286bbSRafal Ozieblo } 1052512286bbSRafal Ozieblo 1053512286bbSRafal Ozieblo /* per queue statistics, each should be unsigned long type */ 1054512286bbSRafal Ozieblo struct queue_stats { 1055512286bbSRafal Ozieblo union { 1056512286bbSRafal Ozieblo unsigned long first; 1057512286bbSRafal Ozieblo unsigned long rx_packets; 1058512286bbSRafal Ozieblo }; 1059512286bbSRafal Ozieblo unsigned long rx_bytes; 1060512286bbSRafal Ozieblo unsigned long rx_dropped; 1061512286bbSRafal Ozieblo unsigned long tx_packets; 1062512286bbSRafal Ozieblo unsigned long tx_bytes; 1063512286bbSRafal Ozieblo unsigned long tx_dropped; 1064512286bbSRafal Ozieblo }; 1065512286bbSRafal Ozieblo 1066512286bbSRafal Ozieblo static const struct gem_statistic queue_statistics[] = { 1067512286bbSRafal Ozieblo QUEUE_STAT_TITLE("rx_packets"), 1068512286bbSRafal Ozieblo QUEUE_STAT_TITLE("rx_bytes"), 1069512286bbSRafal Ozieblo QUEUE_STAT_TITLE("rx_dropped"), 1070512286bbSRafal Ozieblo QUEUE_STAT_TITLE("tx_packets"), 1071512286bbSRafal Ozieblo QUEUE_STAT_TITLE("tx_bytes"), 1072512286bbSRafal Ozieblo QUEUE_STAT_TITLE("tx_dropped"), 1073512286bbSRafal Ozieblo }; 1074512286bbSRafal Ozieblo 1075512286bbSRafal Ozieblo #define QUEUE_STATS_LEN ARRAY_SIZE(queue_statistics) 1076512286bbSRafal Ozieblo 10774df95131SNicolas Ferre struct macb; 1078ae1f2a56SRafal Ozieblo struct macb_queue; 10794df95131SNicolas Ferre 10804df95131SNicolas Ferre struct macb_or_gem_ops { 10814df95131SNicolas Ferre int (*mog_alloc_rx_buffers)(struct macb *bp); 10824df95131SNicolas Ferre void (*mog_free_rx_buffers)(struct macb *bp); 10834df95131SNicolas Ferre void (*mog_init_rings)(struct macb *bp); 108497236cdaSAntoine Tenart int (*mog_rx)(struct macb_queue *queue, struct napi_struct *napi, 108597236cdaSAntoine Tenart int budget); 10864df95131SNicolas Ferre }; 10874df95131SNicolas Ferre 1088c2594d80SAndrei.Pistirica@microchip.com /* MACB-PTP interface: adapt to platform needs. */ 1089c2594d80SAndrei.Pistirica@microchip.com struct macb_ptp_info { 1090c2594d80SAndrei.Pistirica@microchip.com void (*ptp_init)(struct net_device *ndev); 1091c2594d80SAndrei.Pistirica@microchip.com void (*ptp_remove)(struct net_device *ndev); 1092c2594d80SAndrei.Pistirica@microchip.com s32 (*get_ptp_max_adj)(void); 1093c2594d80SAndrei.Pistirica@microchip.com unsigned int (*get_tsu_rate)(struct macb *bp); 1094c2594d80SAndrei.Pistirica@microchip.com int (*get_ts_info)(struct net_device *dev, 1095c2594d80SAndrei.Pistirica@microchip.com struct ethtool_ts_info *info); 1096c2594d80SAndrei.Pistirica@microchip.com int (*get_hwtst)(struct net_device *netdev, 1097c2594d80SAndrei.Pistirica@microchip.com struct ifreq *ifr); 1098c2594d80SAndrei.Pistirica@microchip.com int (*set_hwtst)(struct net_device *netdev, 1099c2594d80SAndrei.Pistirica@microchip.com struct ifreq *ifr, int cmd); 1100c2594d80SAndrei.Pistirica@microchip.com }; 1101c2594d80SAndrei.Pistirica@microchip.com 1102c1e85c6cSClaudiu Beznea struct macb_pm_data { 1103c1e85c6cSClaudiu Beznea u32 scrt2; 1104c1e85c6cSClaudiu Beznea u32 usrio; 1105c1e85c6cSClaudiu Beznea }; 1106c1e85c6cSClaudiu Beznea 1107e175587fSNicolas Ferre struct macb_config { 1108e175587fSNicolas Ferre u32 caps; 1109e175587fSNicolas Ferre unsigned int dma_burst_length; 1110c69618b3SNicolas Ferre int (*clk_init)(struct platform_device *pdev, struct clk **pclk, 1111aead88bdSshubhrajyoti.datta@xilinx.com struct clk **hclk, struct clk **tx_clk, 1112f5473d1dSHarini Katakam struct clk **rx_clk, struct clk **tsu_clk); 1113421d9df0SCyrille Pitchen int (*init)(struct platform_device *pdev); 111498b5a0f4SHarini Katakam int jumbo_max_len; 1115e175587fSNicolas Ferre }; 1116e175587fSNicolas Ferre 1117ab91f0a9SRafal Ozieblo struct tsu_incr { 1118ab91f0a9SRafal Ozieblo u32 sub_ns; 1119ab91f0a9SRafal Ozieblo u32 ns; 1120ab91f0a9SRafal Ozieblo }; 1121ab91f0a9SRafal Ozieblo 112202c958ddSCyrille Pitchen struct macb_queue { 112302c958ddSCyrille Pitchen struct macb *bp; 112402c958ddSCyrille Pitchen int irq; 112502c958ddSCyrille Pitchen 112602c958ddSCyrille Pitchen unsigned int ISR; 112702c958ddSCyrille Pitchen unsigned int IER; 112802c958ddSCyrille Pitchen unsigned int IDR; 112902c958ddSCyrille Pitchen unsigned int IMR; 113002c958ddSCyrille Pitchen unsigned int TBQP; 1131fff8019aSHarini Katakam unsigned int TBQPH; 1132ae1f2a56SRafal Ozieblo unsigned int RBQS; 1133ae1f2a56SRafal Ozieblo unsigned int RBQP; 1134ae1f2a56SRafal Ozieblo unsigned int RBQPH; 113502c958ddSCyrille Pitchen 113602c958ddSCyrille Pitchen unsigned int tx_head, tx_tail; 113702c958ddSCyrille Pitchen struct macb_dma_desc *tx_ring; 113802c958ddSCyrille Pitchen struct macb_tx_skb *tx_skb; 113902c958ddSCyrille Pitchen dma_addr_t tx_ring_dma; 114002c958ddSCyrille Pitchen struct work_struct tx_error_task; 1141ab91f0a9SRafal Ozieblo 1142ae1f2a56SRafal Ozieblo dma_addr_t rx_ring_dma; 1143ae1f2a56SRafal Ozieblo dma_addr_t rx_buffers_dma; 1144ae1f2a56SRafal Ozieblo unsigned int rx_tail; 1145ae1f2a56SRafal Ozieblo unsigned int rx_prepared_head; 1146ae1f2a56SRafal Ozieblo struct macb_dma_desc *rx_ring; 1147ae1f2a56SRafal Ozieblo struct sk_buff **rx_skbuff; 1148ae1f2a56SRafal Ozieblo void *rx_buffers; 1149ae1f2a56SRafal Ozieblo struct napi_struct napi; 1150512286bbSRafal Ozieblo struct queue_stats stats; 1151ae1f2a56SRafal Ozieblo 1152ab91f0a9SRafal Ozieblo #ifdef CONFIG_MACB_USE_HWSTAMP 1153ab91f0a9SRafal Ozieblo struct work_struct tx_ts_task; 1154ab91f0a9SRafal Ozieblo unsigned int tx_ts_head, tx_ts_tail; 1155ab91f0a9SRafal Ozieblo struct gem_tx_ts tx_timestamps[PTP_TS_BUFFER_SIZE]; 1156ab91f0a9SRafal Ozieblo #endif 115702c958ddSCyrille Pitchen }; 115802c958ddSCyrille Pitchen 1159ae8223deSRafal Ozieblo struct ethtool_rx_fs_item { 1160ae8223deSRafal Ozieblo struct ethtool_rx_flow_spec fs; 1161ae8223deSRafal Ozieblo struct list_head list; 1162ae8223deSRafal Ozieblo }; 1163ae8223deSRafal Ozieblo 1164ae8223deSRafal Ozieblo struct ethtool_rx_fs_list { 1165ae8223deSRafal Ozieblo struct list_head list; 1166ae8223deSRafal Ozieblo unsigned int count; 1167ae8223deSRafal Ozieblo }; 1168ae8223deSRafal Ozieblo 11699f2f381fSJeff Kirsher struct macb { 11709f2f381fSJeff Kirsher void __iomem *regs; 1171f2ce8a9eSAndy Shevchenko bool native_io; 1172f2ce8a9eSAndy Shevchenko 1173f2ce8a9eSAndy Shevchenko /* hardware IO accessors */ 11747a6e0706SDavid S. Miller u32 (*macb_reg_readl)(struct macb *bp, int offset); 11757a6e0706SDavid S. Miller void (*macb_reg_writel)(struct macb *bp, int offset, u32 value); 11769f2f381fSJeff Kirsher 11771b44791aSNicolas Ferre size_t rx_buffer_size; 11789f2f381fSJeff Kirsher 1179b410d13eSZach Brown unsigned int rx_ring_size; 1180b410d13eSZach Brown unsigned int tx_ring_size; 1181b410d13eSZach Brown 118202c958ddSCyrille Pitchen unsigned int num_queues; 1183bfa0914aSNicolas Ferre unsigned int queue_mask; 118402c958ddSCyrille Pitchen struct macb_queue queues[MACB_MAX_QUEUES]; 11859f2f381fSJeff Kirsher 11869f2f381fSJeff Kirsher spinlock_t lock; 11879f2f381fSJeff Kirsher struct platform_device *pdev; 11889f2f381fSJeff Kirsher struct clk *pclk; 11899f2f381fSJeff Kirsher struct clk *hclk; 1190e1824dfeSSoren Brinkmann struct clk *tx_clk; 1191aead88bdSshubhrajyoti.datta@xilinx.com struct clk *rx_clk; 1192f5473d1dSHarini Katakam struct clk *tsu_clk; 11939f2f381fSJeff Kirsher struct net_device *dev; 1194a494ed8eSJamie Iles union { 1195a494ed8eSJamie Iles struct macb_stats macb; 1196a494ed8eSJamie Iles struct gem_stats gem; 1197a494ed8eSJamie Iles } hw_stats; 11989f2f381fSJeff Kirsher 11994df95131SNicolas Ferre struct macb_or_gem_ops macbgem_ops; 12004df95131SNicolas Ferre 12019f2f381fSJeff Kirsher struct mii_bus *mii_bus; 12027897b071SAntoine Tenart struct phylink *phylink; 12037897b071SAntoine Tenart struct phylink_config phylink_config; 1204fb97a846SJean-Christophe PLAGNIOL-VILLARD 1205581df9e1SNicolas Ferre u32 caps; 1206e175587fSNicolas Ferre unsigned int dma_burst_length; 1207581df9e1SNicolas Ferre 1208fb97a846SJean-Christophe PLAGNIOL-VILLARD phy_interface_t phy_interface; 1209b85008b7SJoachim Eastwood 12104dda6f6dSJoachim Eastwood /* AT91RM9200 transmit */ 1211b85008b7SJoachim Eastwood struct sk_buff *skb; /* holds skb until xmit interrupt completes */ 1212b85008b7SJoachim Eastwood dma_addr_t skb_physaddr; /* phys addr from pci_map_single */ 1213b85008b7SJoachim Eastwood int skb_length; /* saved skb length for pci_unmap_single */ 1214a4c35ed3SCyrille Pitchen unsigned int max_tx_length; 12153ff13f1cSXander Huff 1216512286bbSRafal Ozieblo u64 ethtool_stats[GEM_STATS_LEN + QUEUE_STATS_LEN * MACB_MAX_QUEUES]; 121798b5a0f4SHarini Katakam 121898b5a0f4SHarini Katakam unsigned int rx_frm_len_mask; 121998b5a0f4SHarini Katakam unsigned int jumbo_max_len; 12203e2a5e15SSergio Prado 12213e2a5e15SSergio Prado u32 wol; 1222c2594d80SAndrei.Pistirica@microchip.com 1223c2594d80SAndrei.Pistirica@microchip.com struct macb_ptp_info *ptp_info; /* macb-ptp interface */ 12247b429614SRafal Ozieblo #ifdef MACB_EXT_DESC 12257b429614SRafal Ozieblo uint8_t hw_dma_cap; 1226dc97a89eSRafal Ozieblo #endif 1227ab91f0a9SRafal Ozieblo spinlock_t tsu_clk_lock; /* gem tsu clock locking */ 1228ab91f0a9SRafal Ozieblo unsigned int tsu_rate; 1229ab91f0a9SRafal Ozieblo struct ptp_clock *ptp_clock; 1230ab91f0a9SRafal Ozieblo struct ptp_clock_info ptp_clock_info; 1231ab91f0a9SRafal Ozieblo struct tsu_incr tsu_incr; 1232ab91f0a9SRafal Ozieblo struct hwtstamp_config tstamp_config; 1233ae8223deSRafal Ozieblo 1234ae8223deSRafal Ozieblo /* RX queue filer rule set*/ 1235ae8223deSRafal Ozieblo struct ethtool_rx_fs_list rx_fs_list; 1236ae8223deSRafal Ozieblo spinlock_t rx_fs_lock; 1237ae8223deSRafal Ozieblo unsigned int max_tuples; 1238032dc41bSHarini Katakam 1239032dc41bSHarini Katakam struct tasklet_struct hresp_err_tasklet; 1240404cd086SHarini Katakam 1241404cd086SHarini Katakam int rx_bd_rd_prefetch; 1242404cd086SHarini Katakam int tx_bd_rd_prefetch; 1243e501070eSHarini Katakam 1244e501070eSHarini Katakam u32 rx_intr_mask; 1245c1e85c6cSClaudiu Beznea 1246c1e85c6cSClaudiu Beznea struct macb_pm_data pm_data; 12479f2f381fSJeff Kirsher }; 12489f2f381fSJeff Kirsher 1249ab91f0a9SRafal Ozieblo #ifdef CONFIG_MACB_USE_HWSTAMP 1250ab91f0a9SRafal Ozieblo #define GEM_TSEC_SIZE (GEM_TSH_SIZE + GEM_TSL_SIZE) 1251ab91f0a9SRafal Ozieblo #define TSU_SEC_MAX_VAL (((u64)1 << GEM_TSEC_SIZE) - 1) 1252ab91f0a9SRafal Ozieblo #define TSU_NSEC_MAX_VAL ((1 << GEM_TN_SIZE) - 1) 1253ab91f0a9SRafal Ozieblo 1254ab91f0a9SRafal Ozieblo enum macb_bd_control { 1255ab91f0a9SRafal Ozieblo TSTAMP_DISABLED, 1256ab91f0a9SRafal Ozieblo TSTAMP_FRAME_PTP_EVENT_ONLY, 1257ab91f0a9SRafal Ozieblo TSTAMP_ALL_PTP_FRAMES, 1258ab91f0a9SRafal Ozieblo TSTAMP_ALL_FRAMES, 1259ab91f0a9SRafal Ozieblo }; 1260ab91f0a9SRafal Ozieblo 1261ab91f0a9SRafal Ozieblo void gem_ptp_init(struct net_device *ndev); 1262ab91f0a9SRafal Ozieblo void gem_ptp_remove(struct net_device *ndev); 1263ab91f0a9SRafal Ozieblo int gem_ptp_txstamp(struct macb_queue *queue, struct sk_buff *skb, struct macb_dma_desc *des); 1264ab91f0a9SRafal Ozieblo void gem_ptp_rxstamp(struct macb *bp, struct sk_buff *skb, struct macb_dma_desc *desc); 1265ab91f0a9SRafal Ozieblo static inline int gem_ptp_do_txstamp(struct macb_queue *queue, struct sk_buff *skb, struct macb_dma_desc *desc) 1266ab91f0a9SRafal Ozieblo { 1267ab91f0a9SRafal Ozieblo if (queue->bp->tstamp_config.tx_type == TSTAMP_DISABLED) 1268ab91f0a9SRafal Ozieblo return -ENOTSUPP; 1269ab91f0a9SRafal Ozieblo 1270ab91f0a9SRafal Ozieblo return gem_ptp_txstamp(queue, skb, desc); 1271ab91f0a9SRafal Ozieblo } 1272ab91f0a9SRafal Ozieblo 1273ab91f0a9SRafal Ozieblo static inline void gem_ptp_do_rxstamp(struct macb *bp, struct sk_buff *skb, struct macb_dma_desc *desc) 1274ab91f0a9SRafal Ozieblo { 1275ab91f0a9SRafal Ozieblo if (bp->tstamp_config.rx_filter == TSTAMP_DISABLED) 1276ab91f0a9SRafal Ozieblo return; 1277ab91f0a9SRafal Ozieblo 1278ab91f0a9SRafal Ozieblo gem_ptp_rxstamp(bp, skb, desc); 1279ab91f0a9SRafal Ozieblo } 1280ab91f0a9SRafal Ozieblo int gem_get_hwtst(struct net_device *dev, struct ifreq *rq); 1281ab91f0a9SRafal Ozieblo int gem_set_hwtst(struct net_device *dev, struct ifreq *ifr, int cmd); 1282ab91f0a9SRafal Ozieblo #else 1283ab91f0a9SRafal Ozieblo static inline void gem_ptp_init(struct net_device *ndev) { } 1284ab91f0a9SRafal Ozieblo static inline void gem_ptp_remove(struct net_device *ndev) { } 1285ab91f0a9SRafal Ozieblo 1286ab91f0a9SRafal Ozieblo static inline int gem_ptp_do_txstamp(struct macb_queue *queue, struct sk_buff *skb, struct macb_dma_desc *desc) 1287ab91f0a9SRafal Ozieblo { 1288ab91f0a9SRafal Ozieblo return -1; 1289ab91f0a9SRafal Ozieblo } 1290ab91f0a9SRafal Ozieblo 1291ab91f0a9SRafal Ozieblo static inline void gem_ptp_do_rxstamp(struct macb *bp, struct sk_buff *skb, struct macb_dma_desc *desc) { } 1292ab91f0a9SRafal Ozieblo #endif 1293ab91f0a9SRafal Ozieblo 1294f75ba50bSJamie Iles static inline bool macb_is_gem(struct macb *bp) 1295f75ba50bSJamie Iles { 1296e175587fSNicolas Ferre return !!(bp->caps & MACB_CAPS_MACB_IS_GEM); 1297f75ba50bSJamie Iles } 1298f75ba50bSJamie Iles 1299c2594d80SAndrei.Pistirica@microchip.com static inline bool gem_has_ptp(struct macb *bp) 1300c2594d80SAndrei.Pistirica@microchip.com { 1301c2594d80SAndrei.Pistirica@microchip.com return !!(bp->caps & MACB_CAPS_GEM_HAS_PTP); 1302c2594d80SAndrei.Pistirica@microchip.com } 1303c2594d80SAndrei.Pistirica@microchip.com 130420c168beSAlexandre Belloni /** 130520c168beSAlexandre Belloni * struct macb_platform_data - platform data for MACB Ethernet used for PCI registration 130620c168beSAlexandre Belloni * @pclk: platform clock 130720c168beSAlexandre Belloni * @hclk: AHB clock 130820c168beSAlexandre Belloni */ 130920c168beSAlexandre Belloni struct macb_platform_data { 131020c168beSAlexandre Belloni struct clk *pclk; 131120c168beSAlexandre Belloni struct clk *hclk; 131220c168beSAlexandre Belloni }; 131320c168beSAlexandre Belloni 13149f2f381fSJeff Kirsher #endif /* _MACB_H */ 1315