162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright(c) 2015 EZchip Technologies. 462306a36Sopenharmony_ci */ 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci#ifndef _NPS_ENET_H 762306a36Sopenharmony_ci#define _NPS_ENET_H 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci/* default values */ 1062306a36Sopenharmony_ci#define NPS_ENET_NAPI_POLL_WEIGHT 0x2 1162306a36Sopenharmony_ci#define NPS_ENET_MAX_FRAME_LENGTH 0x3FFF 1262306a36Sopenharmony_ci#define NPS_ENET_GE_MAC_CFG_0_TX_FC_RETR 0x7 1362306a36Sopenharmony_ci#define NPS_ENET_GE_MAC_CFG_0_RX_IFG 0x5 1462306a36Sopenharmony_ci#define NPS_ENET_GE_MAC_CFG_0_TX_IFG 0xC 1562306a36Sopenharmony_ci#define NPS_ENET_GE_MAC_CFG_0_TX_PR_LEN 0x7 1662306a36Sopenharmony_ci#define NPS_ENET_GE_MAC_CFG_2_STAT_EN 0x3 1762306a36Sopenharmony_ci#define NPS_ENET_GE_MAC_CFG_3_RX_IFG_TH 0x14 1862306a36Sopenharmony_ci#define NPS_ENET_GE_MAC_CFG_3_MAX_LEN 0x3FFC 1962306a36Sopenharmony_ci#define NPS_ENET_ENABLE 1 2062306a36Sopenharmony_ci#define NPS_ENET_DISABLE 0 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_ci/* register definitions */ 2362306a36Sopenharmony_ci#define NPS_ENET_REG_TX_CTL 0x800 2462306a36Sopenharmony_ci#define NPS_ENET_REG_TX_BUF 0x808 2562306a36Sopenharmony_ci#define NPS_ENET_REG_RX_CTL 0x810 2662306a36Sopenharmony_ci#define NPS_ENET_REG_RX_BUF 0x818 2762306a36Sopenharmony_ci#define NPS_ENET_REG_BUF_INT_ENABLE 0x8C0 2862306a36Sopenharmony_ci#define NPS_ENET_REG_GE_MAC_CFG_0 0x1000 2962306a36Sopenharmony_ci#define NPS_ENET_REG_GE_MAC_CFG_1 0x1004 3062306a36Sopenharmony_ci#define NPS_ENET_REG_GE_MAC_CFG_2 0x1008 3162306a36Sopenharmony_ci#define NPS_ENET_REG_GE_MAC_CFG_3 0x100C 3262306a36Sopenharmony_ci#define NPS_ENET_REG_GE_RST 0x1400 3362306a36Sopenharmony_ci#define NPS_ENET_REG_PHASE_FIFO_CTL 0x1404 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ci/* Tx control register masks and shifts */ 3662306a36Sopenharmony_ci#define TX_CTL_NT_MASK 0x7FF 3762306a36Sopenharmony_ci#define TX_CTL_NT_SHIFT 0 3862306a36Sopenharmony_ci#define TX_CTL_ET_MASK 0x4000 3962306a36Sopenharmony_ci#define TX_CTL_ET_SHIFT 14 4062306a36Sopenharmony_ci#define TX_CTL_CT_MASK 0x8000 4162306a36Sopenharmony_ci#define TX_CTL_CT_SHIFT 15 4262306a36Sopenharmony_ci 4362306a36Sopenharmony_ci/* Rx control register masks and shifts */ 4462306a36Sopenharmony_ci#define RX_CTL_NR_MASK 0x7FF 4562306a36Sopenharmony_ci#define RX_CTL_NR_SHIFT 0 4662306a36Sopenharmony_ci#define RX_CTL_CRC_MASK 0x2000 4762306a36Sopenharmony_ci#define RX_CTL_CRC_SHIFT 13 4862306a36Sopenharmony_ci#define RX_CTL_ER_MASK 0x4000 4962306a36Sopenharmony_ci#define RX_CTL_ER_SHIFT 14 5062306a36Sopenharmony_ci#define RX_CTL_CR_MASK 0x8000 5162306a36Sopenharmony_ci#define RX_CTL_CR_SHIFT 15 5262306a36Sopenharmony_ci 5362306a36Sopenharmony_ci/* Interrupt enable for data buffer events register masks and shifts */ 5462306a36Sopenharmony_ci#define RX_RDY_MASK 0x1 5562306a36Sopenharmony_ci#define RX_RDY_SHIFT 0 5662306a36Sopenharmony_ci#define TX_DONE_MASK 0x2 5762306a36Sopenharmony_ci#define TX_DONE_SHIFT 1 5862306a36Sopenharmony_ci 5962306a36Sopenharmony_ci/* Gbps Eth MAC Configuration 0 register masks and shifts */ 6062306a36Sopenharmony_ci#define CFG_0_RX_EN_MASK 0x1 6162306a36Sopenharmony_ci#define CFG_0_RX_EN_SHIFT 0 6262306a36Sopenharmony_ci#define CFG_0_TX_EN_MASK 0x2 6362306a36Sopenharmony_ci#define CFG_0_TX_EN_SHIFT 1 6462306a36Sopenharmony_ci#define CFG_0_TX_FC_EN_MASK 0x4 6562306a36Sopenharmony_ci#define CFG_0_TX_FC_EN_SHIFT 2 6662306a36Sopenharmony_ci#define CFG_0_TX_PAD_EN_MASK 0x8 6762306a36Sopenharmony_ci#define CFG_0_TX_PAD_EN_SHIFT 3 6862306a36Sopenharmony_ci#define CFG_0_TX_CRC_EN_MASK 0x10 6962306a36Sopenharmony_ci#define CFG_0_TX_CRC_EN_SHIFT 4 7062306a36Sopenharmony_ci#define CFG_0_RX_FC_EN_MASK 0x20 7162306a36Sopenharmony_ci#define CFG_0_RX_FC_EN_SHIFT 5 7262306a36Sopenharmony_ci#define CFG_0_RX_CRC_STRIP_MASK 0x40 7362306a36Sopenharmony_ci#define CFG_0_RX_CRC_STRIP_SHIFT 6 7462306a36Sopenharmony_ci#define CFG_0_RX_CRC_IGNORE_MASK 0x80 7562306a36Sopenharmony_ci#define CFG_0_RX_CRC_IGNORE_SHIFT 7 7662306a36Sopenharmony_ci#define CFG_0_RX_LENGTH_CHECK_EN_MASK 0x100 7762306a36Sopenharmony_ci#define CFG_0_RX_LENGTH_CHECK_EN_SHIFT 8 7862306a36Sopenharmony_ci#define CFG_0_TX_FC_RETR_MASK 0xE00 7962306a36Sopenharmony_ci#define CFG_0_TX_FC_RETR_SHIFT 9 8062306a36Sopenharmony_ci#define CFG_0_RX_IFG_MASK 0xF000 8162306a36Sopenharmony_ci#define CFG_0_RX_IFG_SHIFT 12 8262306a36Sopenharmony_ci#define CFG_0_TX_IFG_MASK 0x3F0000 8362306a36Sopenharmony_ci#define CFG_0_TX_IFG_SHIFT 16 8462306a36Sopenharmony_ci#define CFG_0_RX_PR_CHECK_EN_MASK 0x400000 8562306a36Sopenharmony_ci#define CFG_0_RX_PR_CHECK_EN_SHIFT 22 8662306a36Sopenharmony_ci#define CFG_0_NIB_MODE_MASK 0x800000 8762306a36Sopenharmony_ci#define CFG_0_NIB_MODE_SHIFT 23 8862306a36Sopenharmony_ci#define CFG_0_TX_IFG_NIB_MASK 0xF000000 8962306a36Sopenharmony_ci#define CFG_0_TX_IFG_NIB_SHIFT 24 9062306a36Sopenharmony_ci#define CFG_0_TX_PR_LEN_MASK 0xF0000000 9162306a36Sopenharmony_ci#define CFG_0_TX_PR_LEN_SHIFT 28 9262306a36Sopenharmony_ci 9362306a36Sopenharmony_ci/* Gbps Eth MAC Configuration 1 register masks and shifts */ 9462306a36Sopenharmony_ci#define CFG_1_OCTET_0_MASK 0x000000FF 9562306a36Sopenharmony_ci#define CFG_1_OCTET_0_SHIFT 0 9662306a36Sopenharmony_ci#define CFG_1_OCTET_1_MASK 0x0000FF00 9762306a36Sopenharmony_ci#define CFG_1_OCTET_1_SHIFT 8 9862306a36Sopenharmony_ci#define CFG_1_OCTET_2_MASK 0x00FF0000 9962306a36Sopenharmony_ci#define CFG_1_OCTET_2_SHIFT 16 10062306a36Sopenharmony_ci#define CFG_1_OCTET_3_MASK 0xFF000000 10162306a36Sopenharmony_ci#define CFG_1_OCTET_3_SHIFT 24 10262306a36Sopenharmony_ci 10362306a36Sopenharmony_ci/* Gbps Eth MAC Configuration 2 register masks and shifts */ 10462306a36Sopenharmony_ci#define CFG_2_OCTET_4_MASK 0x000000FF 10562306a36Sopenharmony_ci#define CFG_2_OCTET_4_SHIFT 0 10662306a36Sopenharmony_ci#define CFG_2_OCTET_5_MASK 0x0000FF00 10762306a36Sopenharmony_ci#define CFG_2_OCTET_5_SHIFT 8 10862306a36Sopenharmony_ci#define CFG_2_DISK_MC_MASK 0x00100000 10962306a36Sopenharmony_ci#define CFG_2_DISK_MC_SHIFT 20 11062306a36Sopenharmony_ci#define CFG_2_DISK_BC_MASK 0x00200000 11162306a36Sopenharmony_ci#define CFG_2_DISK_BC_SHIFT 21 11262306a36Sopenharmony_ci#define CFG_2_DISK_DA_MASK 0x00400000 11362306a36Sopenharmony_ci#define CFG_2_DISK_DA_SHIFT 22 11462306a36Sopenharmony_ci#define CFG_2_STAT_EN_MASK 0x3000000 11562306a36Sopenharmony_ci#define CFG_2_STAT_EN_SHIFT 24 11662306a36Sopenharmony_ci#define CFG_2_TRANSMIT_FLUSH_EN_MASK 0x80000000 11762306a36Sopenharmony_ci#define CFG_2_TRANSMIT_FLUSH_EN_SHIFT 31 11862306a36Sopenharmony_ci 11962306a36Sopenharmony_ci/* Gbps Eth MAC Configuration 3 register masks and shifts */ 12062306a36Sopenharmony_ci#define CFG_3_TM_HD_MODE_MASK 0x1 12162306a36Sopenharmony_ci#define CFG_3_TM_HD_MODE_SHIFT 0 12262306a36Sopenharmony_ci#define CFG_3_RX_CBFC_EN_MASK 0x2 12362306a36Sopenharmony_ci#define CFG_3_RX_CBFC_EN_SHIFT 1 12462306a36Sopenharmony_ci#define CFG_3_RX_CBFC_REDIR_EN_MASK 0x4 12562306a36Sopenharmony_ci#define CFG_3_RX_CBFC_REDIR_EN_SHIFT 2 12662306a36Sopenharmony_ci#define CFG_3_REDIRECT_CBFC_SEL_MASK 0x18 12762306a36Sopenharmony_ci#define CFG_3_REDIRECT_CBFC_SEL_SHIFT 3 12862306a36Sopenharmony_ci#define CFG_3_CF_DROP_MASK 0x20 12962306a36Sopenharmony_ci#define CFG_3_CF_DROP_SHIFT 5 13062306a36Sopenharmony_ci#define CFG_3_CF_TIMEOUT_MASK 0x3C0 13162306a36Sopenharmony_ci#define CFG_3_CF_TIMEOUT_SHIFT 6 13262306a36Sopenharmony_ci#define CFG_3_RX_IFG_TH_MASK 0x7C00 13362306a36Sopenharmony_ci#define CFG_3_RX_IFG_TH_SHIFT 10 13462306a36Sopenharmony_ci#define CFG_3_TX_CBFC_EN_MASK 0x8000 13562306a36Sopenharmony_ci#define CFG_3_TX_CBFC_EN_SHIFT 15 13662306a36Sopenharmony_ci#define CFG_3_MAX_LEN_MASK 0x3FFF0000 13762306a36Sopenharmony_ci#define CFG_3_MAX_LEN_SHIFT 16 13862306a36Sopenharmony_ci#define CFG_3_EXT_OOB_CBFC_SEL_MASK 0xC0000000 13962306a36Sopenharmony_ci#define CFG_3_EXT_OOB_CBFC_SEL_SHIFT 30 14062306a36Sopenharmony_ci 14162306a36Sopenharmony_ci/* GE MAC, PCS reset control register masks and shifts */ 14262306a36Sopenharmony_ci#define RST_SPCS_MASK 0x1 14362306a36Sopenharmony_ci#define RST_SPCS_SHIFT 0 14462306a36Sopenharmony_ci#define RST_GMAC_0_MASK 0x100 14562306a36Sopenharmony_ci#define RST_GMAC_0_SHIFT 8 14662306a36Sopenharmony_ci 14762306a36Sopenharmony_ci/* Tx phase sync FIFO control register masks and shifts */ 14862306a36Sopenharmony_ci#define PHASE_FIFO_CTL_RST_MASK 0x1 14962306a36Sopenharmony_ci#define PHASE_FIFO_CTL_RST_SHIFT 0 15062306a36Sopenharmony_ci#define PHASE_FIFO_CTL_INIT_MASK 0x2 15162306a36Sopenharmony_ci#define PHASE_FIFO_CTL_INIT_SHIFT 1 15262306a36Sopenharmony_ci 15362306a36Sopenharmony_ci/** 15462306a36Sopenharmony_ci * struct nps_enet_priv - Storage of ENET's private information. 15562306a36Sopenharmony_ci * @regs_base: Base address of ENET memory-mapped control registers. 15662306a36Sopenharmony_ci * @irq: For RX/TX IRQ number. 15762306a36Sopenharmony_ci * @tx_skb: socket buffer of sent frame. 15862306a36Sopenharmony_ci * @napi: Structure for NAPI. 15962306a36Sopenharmony_ci */ 16062306a36Sopenharmony_cistruct nps_enet_priv { 16162306a36Sopenharmony_ci void __iomem *regs_base; 16262306a36Sopenharmony_ci s32 irq; 16362306a36Sopenharmony_ci struct sk_buff *tx_skb; 16462306a36Sopenharmony_ci struct napi_struct napi; 16562306a36Sopenharmony_ci u32 ge_mac_cfg_2_value; 16662306a36Sopenharmony_ci u32 ge_mac_cfg_3_value; 16762306a36Sopenharmony_ci}; 16862306a36Sopenharmony_ci 16962306a36Sopenharmony_ci/** 17062306a36Sopenharmony_ci * nps_enet_reg_set - Sets ENET register with provided value. 17162306a36Sopenharmony_ci * @priv: Pointer to EZchip ENET private data structure. 17262306a36Sopenharmony_ci * @reg: Register offset from base address. 17362306a36Sopenharmony_ci * @value: Value to set in register. 17462306a36Sopenharmony_ci */ 17562306a36Sopenharmony_cistatic inline void nps_enet_reg_set(struct nps_enet_priv *priv, 17662306a36Sopenharmony_ci s32 reg, s32 value) 17762306a36Sopenharmony_ci{ 17862306a36Sopenharmony_ci iowrite32be(value, priv->regs_base + reg); 17962306a36Sopenharmony_ci} 18062306a36Sopenharmony_ci 18162306a36Sopenharmony_ci/** 18262306a36Sopenharmony_ci * nps_enet_reg_get - Gets value of specified ENET register. 18362306a36Sopenharmony_ci * @priv: Pointer to EZchip ENET private data structure. 18462306a36Sopenharmony_ci * @reg: Register offset from base address. 18562306a36Sopenharmony_ci * 18662306a36Sopenharmony_ci * returns: Value of requested register. 18762306a36Sopenharmony_ci */ 18862306a36Sopenharmony_cistatic inline u32 nps_enet_reg_get(struct nps_enet_priv *priv, s32 reg) 18962306a36Sopenharmony_ci{ 19062306a36Sopenharmony_ci return ioread32be(priv->regs_base + reg); 19162306a36Sopenharmony_ci} 19262306a36Sopenharmony_ci 19362306a36Sopenharmony_ci#endif /* _NPS_ENET_H */ 194