162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci 362306a36Sopenharmony_ci#ifndef XILINX_LL_TEMAC_H 462306a36Sopenharmony_ci#define XILINX_LL_TEMAC_H 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci#include <linux/netdevice.h> 762306a36Sopenharmony_ci#include <linux/of.h> 862306a36Sopenharmony_ci#include <linux/platform_device.h> 962306a36Sopenharmony_ci#include <linux/spinlock.h> 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci#ifdef CONFIG_PPC_DCR 1262306a36Sopenharmony_ci#include <asm/dcr.h> 1362306a36Sopenharmony_ci#include <asm/dcr-regs.h> 1462306a36Sopenharmony_ci#endif 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_ci/* packet size info */ 1762306a36Sopenharmony_ci#define XTE_HDR_SIZE 14 /* size of Ethernet header */ 1862306a36Sopenharmony_ci#define XTE_TRL_SIZE 4 /* size of Ethernet trailer (FCS) */ 1962306a36Sopenharmony_ci#define XTE_JUMBO_MTU 9000 2062306a36Sopenharmony_ci#define XTE_MAX_JUMBO_FRAME_SIZE (XTE_JUMBO_MTU + XTE_HDR_SIZE + XTE_TRL_SIZE) 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_ci/* Configuration options */ 2362306a36Sopenharmony_ci 2462306a36Sopenharmony_ci/* Accept all incoming packets. 2562306a36Sopenharmony_ci * This option defaults to disabled (cleared) 2662306a36Sopenharmony_ci */ 2762306a36Sopenharmony_ci#define XTE_OPTION_PROMISC (1 << 0) 2862306a36Sopenharmony_ci/* Jumbo frame support for Tx & Rx. 2962306a36Sopenharmony_ci * This option defaults to disabled (cleared) 3062306a36Sopenharmony_ci */ 3162306a36Sopenharmony_ci#define XTE_OPTION_JUMBO (1 << 1) 3262306a36Sopenharmony_ci/* VLAN Rx & Tx frame support. 3362306a36Sopenharmony_ci * This option defaults to disabled (cleared) 3462306a36Sopenharmony_ci */ 3562306a36Sopenharmony_ci#define XTE_OPTION_VLAN (1 << 2) 3662306a36Sopenharmony_ci/* Enable recognition of flow control frames on Rx 3762306a36Sopenharmony_ci * This option defaults to enabled (set) 3862306a36Sopenharmony_ci */ 3962306a36Sopenharmony_ci#define XTE_OPTION_FLOW_CONTROL (1 << 4) 4062306a36Sopenharmony_ci/* Strip FCS and PAD from incoming frames. 4162306a36Sopenharmony_ci * Note: PAD from VLAN frames is not stripped. 4262306a36Sopenharmony_ci * This option defaults to disabled (set) 4362306a36Sopenharmony_ci */ 4462306a36Sopenharmony_ci#define XTE_OPTION_FCS_STRIP (1 << 5) 4562306a36Sopenharmony_ci/* Generate FCS field and add PAD automatically for outgoing frames. 4662306a36Sopenharmony_ci * This option defaults to enabled (set) 4762306a36Sopenharmony_ci */ 4862306a36Sopenharmony_ci#define XTE_OPTION_FCS_INSERT (1 << 6) 4962306a36Sopenharmony_ci/* Enable Length/Type error checking for incoming frames. When this option is 5062306a36Sopenharmony_ci * set, the MAC will filter frames that have a mismatched type/length field 5162306a36Sopenharmony_ci * and if XTE_OPTION_REPORT_RXERR is set, the user is notified when these 5262306a36Sopenharmony_ci * types of frames are encountered. When this option is cleared, the MAC will 5362306a36Sopenharmony_ci * allow these types of frames to be received. 5462306a36Sopenharmony_ci * This option defaults to enabled (set) 5562306a36Sopenharmony_ci */ 5662306a36Sopenharmony_ci#define XTE_OPTION_LENTYPE_ERR (1 << 7) 5762306a36Sopenharmony_ci/* Enable the transmitter. 5862306a36Sopenharmony_ci * This option defaults to enabled (set) 5962306a36Sopenharmony_ci */ 6062306a36Sopenharmony_ci#define XTE_OPTION_TXEN (1 << 11) 6162306a36Sopenharmony_ci/* Enable the receiver 6262306a36Sopenharmony_ci * This option defaults to enabled (set) 6362306a36Sopenharmony_ci */ 6462306a36Sopenharmony_ci#define XTE_OPTION_RXEN (1 << 12) 6562306a36Sopenharmony_ci 6662306a36Sopenharmony_ci/* Default options set when device is initialized or reset */ 6762306a36Sopenharmony_ci#define XTE_OPTION_DEFAULTS \ 6862306a36Sopenharmony_ci (XTE_OPTION_TXEN | \ 6962306a36Sopenharmony_ci XTE_OPTION_FLOW_CONTROL | \ 7062306a36Sopenharmony_ci XTE_OPTION_RXEN) 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_ci/* XPS_LL_TEMAC SDMA registers definition */ 7362306a36Sopenharmony_ci 7462306a36Sopenharmony_ci#define TX_NXTDESC_PTR 0x00 /* r */ 7562306a36Sopenharmony_ci#define TX_CURBUF_ADDR 0x01 /* r */ 7662306a36Sopenharmony_ci#define TX_CURBUF_LENGTH 0x02 /* r */ 7762306a36Sopenharmony_ci#define TX_CURDESC_PTR 0x03 /* rw */ 7862306a36Sopenharmony_ci#define TX_TAILDESC_PTR 0x04 /* rw */ 7962306a36Sopenharmony_ci#define TX_CHNL_CTRL 0x05 /* rw */ 8062306a36Sopenharmony_ci/* 8162306a36Sopenharmony_ci * 0:7 24:31 IRQTimeout 8262306a36Sopenharmony_ci * 8:15 16:23 IRQCount 8362306a36Sopenharmony_ci * 16:20 11:15 Reserved 8462306a36Sopenharmony_ci * 21 10 0 8562306a36Sopenharmony_ci * 22 9 UseIntOnEnd 8662306a36Sopenharmony_ci * 23 8 LdIRQCnt 8762306a36Sopenharmony_ci * 24 7 IRQEn 8862306a36Sopenharmony_ci * 25:28 3:6 Reserved 8962306a36Sopenharmony_ci * 29 2 IrqErrEn 9062306a36Sopenharmony_ci * 30 1 IrqDlyEn 9162306a36Sopenharmony_ci * 31 0 IrqCoalEn 9262306a36Sopenharmony_ci */ 9362306a36Sopenharmony_ci#define CHNL_CTRL_IRQ_IOE (1 << 9) 9462306a36Sopenharmony_ci#define CHNL_CTRL_IRQ_EN (1 << 7) 9562306a36Sopenharmony_ci#define CHNL_CTRL_IRQ_ERR_EN (1 << 2) 9662306a36Sopenharmony_ci#define CHNL_CTRL_IRQ_DLY_EN (1 << 1) 9762306a36Sopenharmony_ci#define CHNL_CTRL_IRQ_COAL_EN (1 << 0) 9862306a36Sopenharmony_ci#define TX_IRQ_REG 0x06 /* rw */ 9962306a36Sopenharmony_ci/* 10062306a36Sopenharmony_ci * 0:7 24:31 DltTmrValue 10162306a36Sopenharmony_ci * 8:15 16:23 ClscCntrValue 10262306a36Sopenharmony_ci * 16:17 14:15 Reserved 10362306a36Sopenharmony_ci * 18:21 10:13 ClscCnt 10462306a36Sopenharmony_ci * 22:23 8:9 DlyCnt 10562306a36Sopenharmony_ci * 24:28 3::7 Reserved 10662306a36Sopenharmony_ci * 29 2 ErrIrq 10762306a36Sopenharmony_ci * 30 1 DlyIrq 10862306a36Sopenharmony_ci * 31 0 CoalIrq 10962306a36Sopenharmony_ci */ 11062306a36Sopenharmony_ci#define TX_CHNL_STS 0x07 /* r */ 11162306a36Sopenharmony_ci/* 11262306a36Sopenharmony_ci * 0:9 22:31 Reserved 11362306a36Sopenharmony_ci * 10 21 TailPErr 11462306a36Sopenharmony_ci * 11 20 CmpErr 11562306a36Sopenharmony_ci * 12 19 AddrErr 11662306a36Sopenharmony_ci * 13 18 NxtPErr 11762306a36Sopenharmony_ci * 14 17 CurPErr 11862306a36Sopenharmony_ci * 15 16 BsyWr 11962306a36Sopenharmony_ci * 16:23 8:15 Reserved 12062306a36Sopenharmony_ci * 24 7 Error 12162306a36Sopenharmony_ci * 25 6 IOE 12262306a36Sopenharmony_ci * 26 5 SOE 12362306a36Sopenharmony_ci * 27 4 Cmplt 12462306a36Sopenharmony_ci * 28 3 SOP 12562306a36Sopenharmony_ci * 29 2 EOP 12662306a36Sopenharmony_ci * 30 1 EngBusy 12762306a36Sopenharmony_ci * 31 0 Reserved 12862306a36Sopenharmony_ci */ 12962306a36Sopenharmony_ci 13062306a36Sopenharmony_ci#define RX_NXTDESC_PTR 0x08 /* r */ 13162306a36Sopenharmony_ci#define RX_CURBUF_ADDR 0x09 /* r */ 13262306a36Sopenharmony_ci#define RX_CURBUF_LENGTH 0x0a /* r */ 13362306a36Sopenharmony_ci#define RX_CURDESC_PTR 0x0b /* rw */ 13462306a36Sopenharmony_ci#define RX_TAILDESC_PTR 0x0c /* rw */ 13562306a36Sopenharmony_ci#define RX_CHNL_CTRL 0x0d /* rw */ 13662306a36Sopenharmony_ci/* 13762306a36Sopenharmony_ci * 0:7 24:31 IRQTimeout 13862306a36Sopenharmony_ci * 8:15 16:23 IRQCount 13962306a36Sopenharmony_ci * 16:20 11:15 Reserved 14062306a36Sopenharmony_ci * 21 10 0 14162306a36Sopenharmony_ci * 22 9 UseIntOnEnd 14262306a36Sopenharmony_ci * 23 8 LdIRQCnt 14362306a36Sopenharmony_ci * 24 7 IRQEn 14462306a36Sopenharmony_ci * 25:28 3:6 Reserved 14562306a36Sopenharmony_ci * 29 2 IrqErrEn 14662306a36Sopenharmony_ci * 30 1 IrqDlyEn 14762306a36Sopenharmony_ci * 31 0 IrqCoalEn 14862306a36Sopenharmony_ci */ 14962306a36Sopenharmony_ci#define RX_IRQ_REG 0x0e /* rw */ 15062306a36Sopenharmony_ci#define IRQ_COAL (1 << 0) 15162306a36Sopenharmony_ci#define IRQ_DLY (1 << 1) 15262306a36Sopenharmony_ci#define IRQ_ERR (1 << 2) 15362306a36Sopenharmony_ci#define IRQ_DMAERR (1 << 7) /* this is not documented ??? */ 15462306a36Sopenharmony_ci/* 15562306a36Sopenharmony_ci * 0:7 24:31 DltTmrValue 15662306a36Sopenharmony_ci * 8:15 16:23 ClscCntrValue 15762306a36Sopenharmony_ci * 16:17 14:15 Reserved 15862306a36Sopenharmony_ci * 18:21 10:13 ClscCnt 15962306a36Sopenharmony_ci * 22:23 8:9 DlyCnt 16062306a36Sopenharmony_ci * 24:28 3::7 Reserved 16162306a36Sopenharmony_ci */ 16262306a36Sopenharmony_ci#define RX_CHNL_STS 0x0f /* r */ 16362306a36Sopenharmony_ci#define CHNL_STS_ENGBUSY (1 << 1) 16462306a36Sopenharmony_ci#define CHNL_STS_EOP (1 << 2) 16562306a36Sopenharmony_ci#define CHNL_STS_SOP (1 << 3) 16662306a36Sopenharmony_ci#define CHNL_STS_CMPLT (1 << 4) 16762306a36Sopenharmony_ci#define CHNL_STS_SOE (1 << 5) 16862306a36Sopenharmony_ci#define CHNL_STS_IOE (1 << 6) 16962306a36Sopenharmony_ci#define CHNL_STS_ERR (1 << 7) 17062306a36Sopenharmony_ci 17162306a36Sopenharmony_ci#define CHNL_STS_BSYWR (1 << 16) 17262306a36Sopenharmony_ci#define CHNL_STS_CURPERR (1 << 17) 17362306a36Sopenharmony_ci#define CHNL_STS_NXTPERR (1 << 18) 17462306a36Sopenharmony_ci#define CHNL_STS_ADDRERR (1 << 19) 17562306a36Sopenharmony_ci#define CHNL_STS_CMPERR (1 << 20) 17662306a36Sopenharmony_ci#define CHNL_STS_TAILERR (1 << 21) 17762306a36Sopenharmony_ci/* 17862306a36Sopenharmony_ci * 0:9 22:31 Reserved 17962306a36Sopenharmony_ci * 10 21 TailPErr 18062306a36Sopenharmony_ci * 11 20 CmpErr 18162306a36Sopenharmony_ci * 12 19 AddrErr 18262306a36Sopenharmony_ci * 13 18 NxtPErr 18362306a36Sopenharmony_ci * 14 17 CurPErr 18462306a36Sopenharmony_ci * 15 16 BsyWr 18562306a36Sopenharmony_ci * 16:23 8:15 Reserved 18662306a36Sopenharmony_ci * 24 7 Error 18762306a36Sopenharmony_ci * 25 6 IOE 18862306a36Sopenharmony_ci * 26 5 SOE 18962306a36Sopenharmony_ci * 27 4 Cmplt 19062306a36Sopenharmony_ci * 28 3 SOP 19162306a36Sopenharmony_ci * 29 2 EOP 19262306a36Sopenharmony_ci * 30 1 EngBusy 19362306a36Sopenharmony_ci * 31 0 Reserved 19462306a36Sopenharmony_ci */ 19562306a36Sopenharmony_ci 19662306a36Sopenharmony_ci#define DMA_CONTROL_REG 0x10 /* rw */ 19762306a36Sopenharmony_ci#define DMA_CONTROL_RST (1 << 0) 19862306a36Sopenharmony_ci#define DMA_TAIL_ENABLE (1 << 2) 19962306a36Sopenharmony_ci 20062306a36Sopenharmony_ci/* XPS_LL_TEMAC direct registers definition */ 20162306a36Sopenharmony_ci 20262306a36Sopenharmony_ci#define XTE_RAF0_OFFSET 0x00 20362306a36Sopenharmony_ci#define RAF0_RST (1 << 0) 20462306a36Sopenharmony_ci#define RAF0_MCSTREJ (1 << 1) 20562306a36Sopenharmony_ci#define RAF0_BCSTREJ (1 << 2) 20662306a36Sopenharmony_ci#define XTE_TPF0_OFFSET 0x04 20762306a36Sopenharmony_ci#define XTE_IFGP0_OFFSET 0x08 20862306a36Sopenharmony_ci#define XTE_ISR0_OFFSET 0x0c 20962306a36Sopenharmony_ci#define ISR0_HARDACSCMPLT (1 << 0) 21062306a36Sopenharmony_ci#define ISR0_AUTONEG (1 << 1) 21162306a36Sopenharmony_ci#define ISR0_RXCMPLT (1 << 2) 21262306a36Sopenharmony_ci#define ISR0_RXREJ (1 << 3) 21362306a36Sopenharmony_ci#define ISR0_RXFIFOOVR (1 << 4) 21462306a36Sopenharmony_ci#define ISR0_TXCMPLT (1 << 5) 21562306a36Sopenharmony_ci#define ISR0_RXDCMLCK (1 << 6) 21662306a36Sopenharmony_ci 21762306a36Sopenharmony_ci#define XTE_IPR0_OFFSET 0x10 21862306a36Sopenharmony_ci#define XTE_IER0_OFFSET 0x14 21962306a36Sopenharmony_ci 22062306a36Sopenharmony_ci#define XTE_MSW0_OFFSET 0x20 22162306a36Sopenharmony_ci#define XTE_LSW0_OFFSET 0x24 22262306a36Sopenharmony_ci#define XTE_CTL0_OFFSET 0x28 22362306a36Sopenharmony_ci#define XTE_RDY0_OFFSET 0x2c 22462306a36Sopenharmony_ci 22562306a36Sopenharmony_ci#define XTE_RSE_MIIM_RR_MASK 0x0002 22662306a36Sopenharmony_ci#define XTE_RSE_MIIM_WR_MASK 0x0004 22762306a36Sopenharmony_ci#define XTE_RSE_CFG_RR_MASK 0x0020 22862306a36Sopenharmony_ci#define XTE_RSE_CFG_WR_MASK 0x0040 22962306a36Sopenharmony_ci#define XTE_RDY0_HARD_ACS_RDY_MASK (0x10000) 23062306a36Sopenharmony_ci 23162306a36Sopenharmony_ci/* XPS_LL_TEMAC indirect registers offset definition */ 23262306a36Sopenharmony_ci 23362306a36Sopenharmony_ci#define XTE_RXC0_OFFSET 0x00000200 /* Rx configuration word 0 */ 23462306a36Sopenharmony_ci#define XTE_RXC1_OFFSET 0x00000240 /* Rx configuration word 1 */ 23562306a36Sopenharmony_ci#define XTE_RXC1_RXRST_MASK (1 << 31) /* Receiver reset */ 23662306a36Sopenharmony_ci#define XTE_RXC1_RXJMBO_MASK (1 << 30) /* Jumbo frame enable */ 23762306a36Sopenharmony_ci#define XTE_RXC1_RXFCS_MASK (1 << 29) /* FCS not stripped */ 23862306a36Sopenharmony_ci#define XTE_RXC1_RXEN_MASK (1 << 28) /* Receiver enable */ 23962306a36Sopenharmony_ci#define XTE_RXC1_RXVLAN_MASK (1 << 27) /* VLAN enable */ 24062306a36Sopenharmony_ci#define XTE_RXC1_RXHD_MASK (1 << 26) /* Half duplex */ 24162306a36Sopenharmony_ci#define XTE_RXC1_RXLT_MASK (1 << 25) /* Length/type check disable */ 24262306a36Sopenharmony_ci 24362306a36Sopenharmony_ci#define XTE_TXC_OFFSET 0x00000280 /* Tx configuration */ 24462306a36Sopenharmony_ci#define XTE_TXC_TXRST_MASK (1 << 31) /* Transmitter reset */ 24562306a36Sopenharmony_ci#define XTE_TXC_TXJMBO_MASK (1 << 30) /* Jumbo frame enable */ 24662306a36Sopenharmony_ci#define XTE_TXC_TXFCS_MASK (1 << 29) /* Generate FCS */ 24762306a36Sopenharmony_ci#define XTE_TXC_TXEN_MASK (1 << 28) /* Transmitter enable */ 24862306a36Sopenharmony_ci#define XTE_TXC_TXVLAN_MASK (1 << 27) /* VLAN enable */ 24962306a36Sopenharmony_ci#define XTE_TXC_TXHD_MASK (1 << 26) /* Half duplex */ 25062306a36Sopenharmony_ci 25162306a36Sopenharmony_ci#define XTE_FCC_OFFSET 0x000002C0 /* Flow control config */ 25262306a36Sopenharmony_ci#define XTE_FCC_RXFLO_MASK (1 << 29) /* Rx flow control enable */ 25362306a36Sopenharmony_ci#define XTE_FCC_TXFLO_MASK (1 << 30) /* Tx flow control enable */ 25462306a36Sopenharmony_ci 25562306a36Sopenharmony_ci#define XTE_EMCFG_OFFSET 0x00000300 /* EMAC configuration */ 25662306a36Sopenharmony_ci#define XTE_EMCFG_LINKSPD_MASK 0xC0000000 /* Link speed */ 25762306a36Sopenharmony_ci#define XTE_EMCFG_HOSTEN_MASK (1 << 26) /* Host interface enable */ 25862306a36Sopenharmony_ci#define XTE_EMCFG_LINKSPD_10 0x00000000 /* 10 Mbit LINKSPD_MASK */ 25962306a36Sopenharmony_ci#define XTE_EMCFG_LINKSPD_100 (1 << 30) /* 100 Mbit LINKSPD_MASK */ 26062306a36Sopenharmony_ci#define XTE_EMCFG_LINKSPD_1000 (1 << 31) /* 1000 Mbit LINKSPD_MASK */ 26162306a36Sopenharmony_ci 26262306a36Sopenharmony_ci#define XTE_GMIC_OFFSET 0x00000320 /* RGMII/SGMII config */ 26362306a36Sopenharmony_ci#define XTE_MC_OFFSET 0x00000340 /* MDIO configuration */ 26462306a36Sopenharmony_ci#define XTE_UAW0_OFFSET 0x00000380 /* Unicast address word 0 */ 26562306a36Sopenharmony_ci#define XTE_UAW1_OFFSET 0x00000384 /* Unicast address word 1 */ 26662306a36Sopenharmony_ci 26762306a36Sopenharmony_ci#define XTE_MAW0_OFFSET 0x00000388 /* Multicast addr word 0 */ 26862306a36Sopenharmony_ci#define XTE_MAW1_OFFSET 0x0000038C /* Multicast addr word 1 */ 26962306a36Sopenharmony_ci#define XTE_AFM_OFFSET 0x00000390 /* Promiscuous mode */ 27062306a36Sopenharmony_ci#define XTE_AFM_EPPRM_MASK (1 << 31) /* Promiscuous mode enable */ 27162306a36Sopenharmony_ci 27262306a36Sopenharmony_ci/* Interrupt Request status */ 27362306a36Sopenharmony_ci#define XTE_TIS_OFFSET 0x000003A0 27462306a36Sopenharmony_ci#define TIS_FRIS (1 << 0) 27562306a36Sopenharmony_ci#define TIS_MRIS (1 << 1) 27662306a36Sopenharmony_ci#define TIS_MWIS (1 << 2) 27762306a36Sopenharmony_ci#define TIS_ARIS (1 << 3) 27862306a36Sopenharmony_ci#define TIS_AWIS (1 << 4) 27962306a36Sopenharmony_ci#define TIS_CRIS (1 << 5) 28062306a36Sopenharmony_ci#define TIS_CWIS (1 << 6) 28162306a36Sopenharmony_ci 28262306a36Sopenharmony_ci#define XTE_TIE_OFFSET 0x000003A4 /* Interrupt enable */ 28362306a36Sopenharmony_ci 28462306a36Sopenharmony_ci/* MII Management Control register (MGTCR) */ 28562306a36Sopenharmony_ci#define XTE_MGTDR_OFFSET 0x000003B0 /* MII data */ 28662306a36Sopenharmony_ci#define XTE_MIIMAI_OFFSET 0x000003B4 /* MII control */ 28762306a36Sopenharmony_ci 28862306a36Sopenharmony_ci#define CNTLREG_WRITE_ENABLE_MASK 0x8000 28962306a36Sopenharmony_ci#define CNTLREG_EMAC1SEL_MASK 0x0400 29062306a36Sopenharmony_ci#define CNTLREG_ADDRESSCODE_MASK 0x03ff 29162306a36Sopenharmony_ci 29262306a36Sopenharmony_ci/* CDMAC descriptor status bit definitions */ 29362306a36Sopenharmony_ci 29462306a36Sopenharmony_ci#define STS_CTRL_APP0_ERR (1 << 31) 29562306a36Sopenharmony_ci#define STS_CTRL_APP0_IRQONEND (1 << 30) 29662306a36Sopenharmony_ci/* undocumented */ 29762306a36Sopenharmony_ci#define STS_CTRL_APP0_STOPONEND (1 << 29) 29862306a36Sopenharmony_ci#define STS_CTRL_APP0_CMPLT (1 << 28) 29962306a36Sopenharmony_ci#define STS_CTRL_APP0_SOP (1 << 27) 30062306a36Sopenharmony_ci#define STS_CTRL_APP0_EOP (1 << 26) 30162306a36Sopenharmony_ci#define STS_CTRL_APP0_ENGBUSY (1 << 25) 30262306a36Sopenharmony_ci/* undocumented */ 30362306a36Sopenharmony_ci#define STS_CTRL_APP0_ENGRST (1 << 24) 30462306a36Sopenharmony_ci 30562306a36Sopenharmony_ci#define TX_CONTROL_CALC_CSUM_MASK 1 30662306a36Sopenharmony_ci 30762306a36Sopenharmony_ci#define MULTICAST_CAM_TABLE_NUM 4 30862306a36Sopenharmony_ci 30962306a36Sopenharmony_ci/* TEMAC Synthesis features */ 31062306a36Sopenharmony_ci#define TEMAC_FEATURE_RX_CSUM (1 << 0) 31162306a36Sopenharmony_ci#define TEMAC_FEATURE_TX_CSUM (1 << 1) 31262306a36Sopenharmony_ci 31362306a36Sopenharmony_ci/* TX/RX CURDESC_PTR points to first descriptor */ 31462306a36Sopenharmony_ci/* TX/RX TAILDESC_PTR points to last descriptor in linked list */ 31562306a36Sopenharmony_ci 31662306a36Sopenharmony_ci/** 31762306a36Sopenharmony_ci * struct cdmac_bd - LocalLink buffer descriptor format 31862306a36Sopenharmony_ci * 31962306a36Sopenharmony_ci * app0 bits: 32062306a36Sopenharmony_ci * 0 Error 32162306a36Sopenharmony_ci * 1 IrqOnEnd generate an interrupt at completion of DMA op 32262306a36Sopenharmony_ci * 2 reserved 32362306a36Sopenharmony_ci * 3 completed Current descriptor completed 32462306a36Sopenharmony_ci * 4 SOP TX - marks first desc/ RX marks first desct 32562306a36Sopenharmony_ci * 5 EOP TX marks last desc/RX marks last desc 32662306a36Sopenharmony_ci * 6 EngBusy DMA is processing 32762306a36Sopenharmony_ci * 7 reserved 32862306a36Sopenharmony_ci * 8:31 application specific 32962306a36Sopenharmony_ci */ 33062306a36Sopenharmony_cistruct cdmac_bd { 33162306a36Sopenharmony_ci u32 next; /* Physical address of next buffer descriptor */ 33262306a36Sopenharmony_ci u32 phys; 33362306a36Sopenharmony_ci u32 len; 33462306a36Sopenharmony_ci u32 app0; 33562306a36Sopenharmony_ci u32 app1; /* TX start << 16 | insert */ 33662306a36Sopenharmony_ci u32 app2; /* TX csum */ 33762306a36Sopenharmony_ci u32 app3; 33862306a36Sopenharmony_ci u32 app4; /* skb for TX length for RX */ 33962306a36Sopenharmony_ci}; 34062306a36Sopenharmony_ci 34162306a36Sopenharmony_cistruct temac_local { 34262306a36Sopenharmony_ci struct net_device *ndev; 34362306a36Sopenharmony_ci struct device *dev; 34462306a36Sopenharmony_ci 34562306a36Sopenharmony_ci /* Connection to PHY device */ 34662306a36Sopenharmony_ci struct device_node *phy_node; 34762306a36Sopenharmony_ci /* For non-device-tree devices */ 34862306a36Sopenharmony_ci char phy_name[MII_BUS_ID_SIZE + 3]; 34962306a36Sopenharmony_ci phy_interface_t phy_interface; 35062306a36Sopenharmony_ci 35162306a36Sopenharmony_ci /* MDIO bus data */ 35262306a36Sopenharmony_ci struct mii_bus *mii_bus; /* MII bus reference */ 35362306a36Sopenharmony_ci 35462306a36Sopenharmony_ci /* IO registers, dma functions and IRQs */ 35562306a36Sopenharmony_ci void __iomem *regs; 35662306a36Sopenharmony_ci void __iomem *sdma_regs; 35762306a36Sopenharmony_ci#ifdef CONFIG_PPC_DCR 35862306a36Sopenharmony_ci dcr_host_t sdma_dcrs; 35962306a36Sopenharmony_ci#endif 36062306a36Sopenharmony_ci u32 (*temac_ior)(struct temac_local *lp, int offset); 36162306a36Sopenharmony_ci void (*temac_iow)(struct temac_local *lp, int offset, u32 value); 36262306a36Sopenharmony_ci u32 (*dma_in)(struct temac_local *lp, int reg); 36362306a36Sopenharmony_ci void (*dma_out)(struct temac_local *lp, int reg, u32 value); 36462306a36Sopenharmony_ci 36562306a36Sopenharmony_ci int tx_irq; 36662306a36Sopenharmony_ci int rx_irq; 36762306a36Sopenharmony_ci int emac_num; 36862306a36Sopenharmony_ci 36962306a36Sopenharmony_ci struct sk_buff **rx_skb; 37062306a36Sopenharmony_ci spinlock_t rx_lock; 37162306a36Sopenharmony_ci /* For synchronization of indirect register access. Must be 37262306a36Sopenharmony_ci * shared mutex between interfaces in same TEMAC block. 37362306a36Sopenharmony_ci */ 37462306a36Sopenharmony_ci spinlock_t *indirect_lock; 37562306a36Sopenharmony_ci u32 options; /* Current options word */ 37662306a36Sopenharmony_ci int last_link; 37762306a36Sopenharmony_ci unsigned int temac_features; 37862306a36Sopenharmony_ci 37962306a36Sopenharmony_ci /* Buffer descriptors */ 38062306a36Sopenharmony_ci struct cdmac_bd *tx_bd_v; 38162306a36Sopenharmony_ci dma_addr_t tx_bd_p; 38262306a36Sopenharmony_ci u32 tx_bd_num; 38362306a36Sopenharmony_ci struct cdmac_bd *rx_bd_v; 38462306a36Sopenharmony_ci dma_addr_t rx_bd_p; 38562306a36Sopenharmony_ci u32 rx_bd_num; 38662306a36Sopenharmony_ci int tx_bd_ci; 38762306a36Sopenharmony_ci int tx_bd_tail; 38862306a36Sopenharmony_ci int rx_bd_ci; 38962306a36Sopenharmony_ci int rx_bd_tail; 39062306a36Sopenharmony_ci 39162306a36Sopenharmony_ci /* DMA channel control setup */ 39262306a36Sopenharmony_ci u8 coalesce_count_tx; 39362306a36Sopenharmony_ci u8 coalesce_delay_tx; 39462306a36Sopenharmony_ci u8 coalesce_count_rx; 39562306a36Sopenharmony_ci u8 coalesce_delay_rx; 39662306a36Sopenharmony_ci 39762306a36Sopenharmony_ci struct delayed_work restart_work; 39862306a36Sopenharmony_ci}; 39962306a36Sopenharmony_ci 40062306a36Sopenharmony_ci/* Wrappers for temac_ior()/temac_iow() function pointers above */ 40162306a36Sopenharmony_ci#define temac_ior(lp, o) ((lp)->temac_ior(lp, o)) 40262306a36Sopenharmony_ci#define temac_iow(lp, o, v) ((lp)->temac_iow(lp, o, v)) 40362306a36Sopenharmony_ci 40462306a36Sopenharmony_ci/* xilinx_temac.c */ 40562306a36Sopenharmony_ciint temac_indirect_busywait(struct temac_local *lp); 40662306a36Sopenharmony_ciu32 temac_indirect_in32(struct temac_local *lp, int reg); 40762306a36Sopenharmony_ciu32 temac_indirect_in32_locked(struct temac_local *lp, int reg); 40862306a36Sopenharmony_civoid temac_indirect_out32(struct temac_local *lp, int reg, u32 value); 40962306a36Sopenharmony_civoid temac_indirect_out32_locked(struct temac_local *lp, int reg, u32 value); 41062306a36Sopenharmony_ci 41162306a36Sopenharmony_ci/* xilinx_temac_mdio.c */ 41262306a36Sopenharmony_ciint temac_mdio_setup(struct temac_local *lp, struct platform_device *pdev); 41362306a36Sopenharmony_civoid temac_mdio_teardown(struct temac_local *lp); 41462306a36Sopenharmony_ci 41562306a36Sopenharmony_ci#endif /* XILINX_LL_TEMAC_H */ 416