1*97fb5e8dSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */ 2b9b17debSTimur Tabi /* Copyright (c) 2013-2016, The Linux Foundation. All rights reserved. 3b9b17debSTimur Tabi */ 4b9b17debSTimur Tabi 5b9b17debSTimur Tabi #ifndef _EMAC_H_ 6b9b17debSTimur Tabi #define _EMAC_H_ 7b9b17debSTimur Tabi 8b9b17debSTimur Tabi #include <linux/irqreturn.h> 9b9b17debSTimur Tabi #include <linux/netdevice.h> 10b9b17debSTimur Tabi #include <linux/clk.h> 11b9b17debSTimur Tabi #include <linux/platform_device.h> 12b9b17debSTimur Tabi #include "emac-mac.h" 13b9b17debSTimur Tabi #include "emac-phy.h" 1441c1093fSTimur Tabi #include "emac-sgmii.h" 15b9b17debSTimur Tabi 16b9b17debSTimur Tabi /* EMAC base register offsets */ 17c4e7beeaSTimur Tabi #define EMAC_DMA_MAS_CTRL 0x1400 18c4e7beeaSTimur Tabi #define EMAC_IRQ_MOD_TIM_INIT 0x1408 19c4e7beeaSTimur Tabi #define EMAC_BLK_IDLE_STS 0x140c 20c4e7beeaSTimur Tabi #define EMAC_PHY_LINK_DELAY 0x141c 21c4e7beeaSTimur Tabi #define EMAC_SYS_ALIV_CTRL 0x1434 22c4e7beeaSTimur Tabi #define EMAC_MAC_CTRL 0x1480 23c4e7beeaSTimur Tabi #define EMAC_MAC_IPGIFG_CTRL 0x1484 24c4e7beeaSTimur Tabi #define EMAC_MAC_STA_ADDR0 0x1488 25c4e7beeaSTimur Tabi #define EMAC_MAC_STA_ADDR1 0x148c 26c4e7beeaSTimur Tabi #define EMAC_HASH_TAB_REG0 0x1490 27c4e7beeaSTimur Tabi #define EMAC_HASH_TAB_REG1 0x1494 28c4e7beeaSTimur Tabi #define EMAC_MAC_HALF_DPLX_CTRL 0x1498 29c4e7beeaSTimur Tabi #define EMAC_MAX_FRAM_LEN_CTRL 0x149c 30c4e7beeaSTimur Tabi #define EMAC_WOL_CTRL0 0x14a0 31c4e7beeaSTimur Tabi #define EMAC_RSS_KEY0 0x14b0 32c4e7beeaSTimur Tabi #define EMAC_H1TPD_BASE_ADDR_LO 0x14e0 33c4e7beeaSTimur Tabi #define EMAC_H2TPD_BASE_ADDR_LO 0x14e4 34c4e7beeaSTimur Tabi #define EMAC_H3TPD_BASE_ADDR_LO 0x14e8 35c4e7beeaSTimur Tabi #define EMAC_INTER_SRAM_PART9 0x1534 36c4e7beeaSTimur Tabi #define EMAC_DESC_CTRL_0 0x1540 37c4e7beeaSTimur Tabi #define EMAC_DESC_CTRL_1 0x1544 38c4e7beeaSTimur Tabi #define EMAC_DESC_CTRL_2 0x1550 39c4e7beeaSTimur Tabi #define EMAC_DESC_CTRL_10 0x1554 40c4e7beeaSTimur Tabi #define EMAC_DESC_CTRL_12 0x1558 41c4e7beeaSTimur Tabi #define EMAC_DESC_CTRL_13 0x155c 42c4e7beeaSTimur Tabi #define EMAC_DESC_CTRL_3 0x1560 43c4e7beeaSTimur Tabi #define EMAC_DESC_CTRL_4 0x1564 44c4e7beeaSTimur Tabi #define EMAC_DESC_CTRL_5 0x1568 45c4e7beeaSTimur Tabi #define EMAC_DESC_CTRL_14 0x156c 46c4e7beeaSTimur Tabi #define EMAC_DESC_CTRL_15 0x1570 47c4e7beeaSTimur Tabi #define EMAC_DESC_CTRL_16 0x1574 48c4e7beeaSTimur Tabi #define EMAC_DESC_CTRL_6 0x1578 49c4e7beeaSTimur Tabi #define EMAC_DESC_CTRL_8 0x1580 50c4e7beeaSTimur Tabi #define EMAC_DESC_CTRL_9 0x1584 51c4e7beeaSTimur Tabi #define EMAC_DESC_CTRL_11 0x1588 52c4e7beeaSTimur Tabi #define EMAC_TXQ_CTRL_0 0x1590 53c4e7beeaSTimur Tabi #define EMAC_TXQ_CTRL_1 0x1594 54c4e7beeaSTimur Tabi #define EMAC_TXQ_CTRL_2 0x1598 55c4e7beeaSTimur Tabi #define EMAC_RXQ_CTRL_0 0x15a0 56c4e7beeaSTimur Tabi #define EMAC_RXQ_CTRL_1 0x15a4 57c4e7beeaSTimur Tabi #define EMAC_RXQ_CTRL_2 0x15a8 58c4e7beeaSTimur Tabi #define EMAC_RXQ_CTRL_3 0x15ac 59c4e7beeaSTimur Tabi #define EMAC_BASE_CPU_NUMBER 0x15b8 60c4e7beeaSTimur Tabi #define EMAC_DMA_CTRL 0x15c0 61c4e7beeaSTimur Tabi #define EMAC_MAILBOX_0 0x15e0 62c4e7beeaSTimur Tabi #define EMAC_MAILBOX_5 0x15e4 63c4e7beeaSTimur Tabi #define EMAC_MAILBOX_6 0x15e8 64c4e7beeaSTimur Tabi #define EMAC_MAILBOX_13 0x15ec 65c4e7beeaSTimur Tabi #define EMAC_MAILBOX_2 0x15f4 66c4e7beeaSTimur Tabi #define EMAC_MAILBOX_3 0x15f8 67c4e7beeaSTimur Tabi #define EMAC_INT_STATUS 0x1600 68c4e7beeaSTimur Tabi #define EMAC_INT_MASK 0x1604 69c4e7beeaSTimur Tabi #define EMAC_MAILBOX_11 0x160c 70c4e7beeaSTimur Tabi #define EMAC_AXI_MAST_CTRL 0x1610 71c4e7beeaSTimur Tabi #define EMAC_MAILBOX_12 0x1614 72c4e7beeaSTimur Tabi #define EMAC_MAILBOX_9 0x1618 73c4e7beeaSTimur Tabi #define EMAC_MAILBOX_10 0x161c 74c4e7beeaSTimur Tabi #define EMAC_ATHR_HEADER_CTRL 0x1620 75c4e7beeaSTimur Tabi #define EMAC_RXMAC_STATC_REG0 0x1700 76c4e7beeaSTimur Tabi #define EMAC_RXMAC_STATC_REG22 0x1758 77c4e7beeaSTimur Tabi #define EMAC_TXMAC_STATC_REG0 0x1760 78c4e7beeaSTimur Tabi #define EMAC_TXMAC_STATC_REG24 0x17c0 79c4e7beeaSTimur Tabi #define EMAC_CLK_GATE_CTRL 0x1814 80c4e7beeaSTimur Tabi #define EMAC_CORE_HW_VERSION 0x1974 81c4e7beeaSTimur Tabi #define EMAC_MISC_CTRL 0x1990 82c4e7beeaSTimur Tabi #define EMAC_MAILBOX_7 0x19e0 83c4e7beeaSTimur Tabi #define EMAC_MAILBOX_8 0x19e4 84c4e7beeaSTimur Tabi #define EMAC_IDT_TABLE0 0x1b00 85c4e7beeaSTimur Tabi #define EMAC_RXMAC_STATC_REG23 0x1bc8 86c4e7beeaSTimur Tabi #define EMAC_RXMAC_STATC_REG24 0x1bcc 87c4e7beeaSTimur Tabi #define EMAC_TXMAC_STATC_REG25 0x1bd0 88c4e7beeaSTimur Tabi #define EMAC_MAILBOX_15 0x1bd4 89c4e7beeaSTimur Tabi #define EMAC_MAILBOX_16 0x1bd8 90c4e7beeaSTimur Tabi #define EMAC_INT1_MASK 0x1bf0 91c4e7beeaSTimur Tabi #define EMAC_INT1_STATUS 0x1bf4 92c4e7beeaSTimur Tabi #define EMAC_INT2_MASK 0x1bf8 93c4e7beeaSTimur Tabi #define EMAC_INT2_STATUS 0x1bfc 94c4e7beeaSTimur Tabi #define EMAC_INT3_MASK 0x1c00 95c4e7beeaSTimur Tabi #define EMAC_INT3_STATUS 0x1c04 96b9b17debSTimur Tabi 97b9b17debSTimur Tabi /* EMAC_DMA_MAS_CTRL */ 98b9b17debSTimur Tabi #define DEV_ID_NUM_BMSK 0x7f000000 99b9b17debSTimur Tabi #define DEV_ID_NUM_SHFT 24 100b9b17debSTimur Tabi #define DEV_REV_NUM_BMSK 0xff0000 101b9b17debSTimur Tabi #define DEV_REV_NUM_SHFT 16 102b9b17debSTimur Tabi #define INT_RD_CLR_EN 0x4000 103b9b17debSTimur Tabi #define IRQ_MODERATOR2_EN 0x800 104b9b17debSTimur Tabi #define IRQ_MODERATOR_EN 0x400 105b9b17debSTimur Tabi #define LPW_CLK_SEL 0x80 106b9b17debSTimur Tabi #define LPW_STATE 0x20 107b9b17debSTimur Tabi #define LPW_MODE 0x10 108b9b17debSTimur Tabi #define SOFT_RST 0x1 109b9b17debSTimur Tabi 110b9b17debSTimur Tabi /* EMAC_IRQ_MOD_TIM_INIT */ 111b9b17debSTimur Tabi #define IRQ_MODERATOR2_INIT_BMSK 0xffff0000 112b9b17debSTimur Tabi #define IRQ_MODERATOR2_INIT_SHFT 16 113b9b17debSTimur Tabi #define IRQ_MODERATOR_INIT_BMSK 0xffff 114b9b17debSTimur Tabi #define IRQ_MODERATOR_INIT_SHFT 0 115b9b17debSTimur Tabi 116b9b17debSTimur Tabi /* EMAC_INT_STATUS */ 117b9b17debSTimur Tabi #define DIS_INT BIT(31) 118b9b17debSTimur Tabi #define PTP_INT BIT(30) 119b9b17debSTimur Tabi #define RFD4_UR_INT BIT(29) 120b9b17debSTimur Tabi #define TX_PKT_INT3 BIT(26) 121b9b17debSTimur Tabi #define TX_PKT_INT2 BIT(25) 122b9b17debSTimur Tabi #define TX_PKT_INT1 BIT(24) 123b9b17debSTimur Tabi #define RX_PKT_INT3 BIT(19) 124b9b17debSTimur Tabi #define RX_PKT_INT2 BIT(18) 125b9b17debSTimur Tabi #define RX_PKT_INT1 BIT(17) 126b9b17debSTimur Tabi #define RX_PKT_INT0 BIT(16) 127b9b17debSTimur Tabi #define TX_PKT_INT BIT(15) 128b9b17debSTimur Tabi #define TXQ_TO_INT BIT(14) 129b9b17debSTimur Tabi #define GPHY_WAKEUP_INT BIT(13) 130b9b17debSTimur Tabi #define GPHY_LINK_DOWN_INT BIT(12) 131b9b17debSTimur Tabi #define GPHY_LINK_UP_INT BIT(11) 132b9b17debSTimur Tabi #define DMAW_TO_INT BIT(10) 133b9b17debSTimur Tabi #define DMAR_TO_INT BIT(9) 134b9b17debSTimur Tabi #define TXF_UR_INT BIT(8) 135b9b17debSTimur Tabi #define RFD3_UR_INT BIT(7) 136b9b17debSTimur Tabi #define RFD2_UR_INT BIT(6) 137b9b17debSTimur Tabi #define RFD1_UR_INT BIT(5) 138b9b17debSTimur Tabi #define RFD0_UR_INT BIT(4) 139b9b17debSTimur Tabi #define RXF_OF_INT BIT(3) 140b9b17debSTimur Tabi #define SW_MAN_INT BIT(2) 141b9b17debSTimur Tabi 142b9b17debSTimur Tabi /* EMAC_MAILBOX_6 */ 143b9b17debSTimur Tabi #define RFD2_PROC_IDX_BMSK 0xfff0000 144b9b17debSTimur Tabi #define RFD2_PROC_IDX_SHFT 16 145b9b17debSTimur Tabi #define RFD2_PROD_IDX_BMSK 0xfff 146b9b17debSTimur Tabi #define RFD2_PROD_IDX_SHFT 0 147b9b17debSTimur Tabi 148b9b17debSTimur Tabi /* EMAC_CORE_HW_VERSION */ 149b9b17debSTimur Tabi #define MAJOR_BMSK 0xf0000000 150b9b17debSTimur Tabi #define MAJOR_SHFT 28 151b9b17debSTimur Tabi #define MINOR_BMSK 0xfff0000 152b9b17debSTimur Tabi #define MINOR_SHFT 16 153b9b17debSTimur Tabi #define STEP_BMSK 0xffff 154b9b17debSTimur Tabi #define STEP_SHFT 0 155b9b17debSTimur Tabi 156b9b17debSTimur Tabi /* EMAC_EMAC_WRAPPER_CSR1 */ 157b9b17debSTimur Tabi #define TX_INDX_FIFO_SYNC_RST BIT(23) 158b9b17debSTimur Tabi #define TX_TS_FIFO_SYNC_RST BIT(22) 159b9b17debSTimur Tabi #define RX_TS_FIFO2_SYNC_RST BIT(21) 160b9b17debSTimur Tabi #define RX_TS_FIFO1_SYNC_RST BIT(20) 161b9b17debSTimur Tabi #define TX_TS_ENABLE BIT(16) 162b9b17debSTimur Tabi #define DIS_1588_CLKS BIT(11) 163b9b17debSTimur Tabi #define FREQ_MODE BIT(9) 164b9b17debSTimur Tabi #define ENABLE_RRD_TIMESTAMP BIT(3) 165b9b17debSTimur Tabi 166b9b17debSTimur Tabi /* EMAC_EMAC_WRAPPER_CSR2 */ 167b9b17debSTimur Tabi #define HDRIVE_BMSK 0x3000 168b9b17debSTimur Tabi #define HDRIVE_SHFT 12 169b9b17debSTimur Tabi #define SLB_EN BIT(9) 170b9b17debSTimur Tabi #define PLB_EN BIT(8) 171b9b17debSTimur Tabi #define WOL_EN BIT(3) 172b9b17debSTimur Tabi #define PHY_RESET BIT(0) 173b9b17debSTimur Tabi 174b9b17debSTimur Tabi #define EMAC_DEV_ID 0x0040 175b9b17debSTimur Tabi 176b9b17debSTimur Tabi /* SGMII v2 per lane registers */ 177b9b17debSTimur Tabi #define SGMII_LN_RSM_START 0x029C 178b9b17debSTimur Tabi 179b9b17debSTimur Tabi /* SGMII v2 PHY common registers */ 180b9b17debSTimur Tabi #define SGMII_PHY_CMN_CTRL 0x0408 181b9b17debSTimur Tabi #define SGMII_PHY_CMN_RESET_CTRL 0x0410 182b9b17debSTimur Tabi 183b9b17debSTimur Tabi /* SGMII v2 PHY registers per lane */ 184b9b17debSTimur Tabi #define SGMII_PHY_LN_OFFSET 0x0400 185b9b17debSTimur Tabi #define SGMII_PHY_LN_LANE_STATUS 0x00DC 186b9b17debSTimur Tabi #define SGMII_PHY_LN_BIST_GEN0 0x008C 187b9b17debSTimur Tabi #define SGMII_PHY_LN_BIST_GEN1 0x0090 188b9b17debSTimur Tabi #define SGMII_PHY_LN_BIST_GEN2 0x0094 189b9b17debSTimur Tabi #define SGMII_PHY_LN_BIST_GEN3 0x0098 190b9b17debSTimur Tabi #define SGMII_PHY_LN_CDR_CTRL1 0x005C 191b9b17debSTimur Tabi 192b9b17debSTimur Tabi enum emac_clk_id { 193b9b17debSTimur Tabi EMAC_CLK_AXI, 194b9b17debSTimur Tabi EMAC_CLK_CFG_AHB, 195b9b17debSTimur Tabi EMAC_CLK_HIGH_SPEED, 196b9b17debSTimur Tabi EMAC_CLK_MDIO, 197b9b17debSTimur Tabi EMAC_CLK_TX, 198b9b17debSTimur Tabi EMAC_CLK_RX, 199b9b17debSTimur Tabi EMAC_CLK_SYS, 200b9b17debSTimur Tabi EMAC_CLK_CNT 201b9b17debSTimur Tabi }; 202b9b17debSTimur Tabi 203b9b17debSTimur Tabi #define EMAC_LINK_SPEED_UNKNOWN 0x0 204b9b17debSTimur Tabi #define EMAC_LINK_SPEED_10_HALF BIT(0) 205b9b17debSTimur Tabi #define EMAC_LINK_SPEED_10_FULL BIT(1) 206b9b17debSTimur Tabi #define EMAC_LINK_SPEED_100_HALF BIT(2) 207b9b17debSTimur Tabi #define EMAC_LINK_SPEED_100_FULL BIT(3) 208b9b17debSTimur Tabi #define EMAC_LINK_SPEED_1GB_FULL BIT(5) 209b9b17debSTimur Tabi 210b9b17debSTimur Tabi #define EMAC_MAX_SETUP_LNK_CYCLE 100 211b9b17debSTimur Tabi 212b9b17debSTimur Tabi struct emac_stats { 213b9b17debSTimur Tabi /* rx */ 214b9b17debSTimur Tabi u64 rx_ok; /* good packets */ 215b9b17debSTimur Tabi u64 rx_bcast; /* good broadcast packets */ 216b9b17debSTimur Tabi u64 rx_mcast; /* good multicast packets */ 217b9b17debSTimur Tabi u64 rx_pause; /* pause packet */ 218b9b17debSTimur Tabi u64 rx_ctrl; /* control packets other than pause frame. */ 219b9b17debSTimur Tabi u64 rx_fcs_err; /* packets with bad FCS. */ 220b9b17debSTimur Tabi u64 rx_len_err; /* packets with length mismatch */ 221b9b17debSTimur Tabi u64 rx_byte_cnt; /* good bytes count (without FCS) */ 222b9b17debSTimur Tabi u64 rx_runt; /* runt packets */ 223b9b17debSTimur Tabi u64 rx_frag; /* fragment count */ 224b9b17debSTimur Tabi u64 rx_sz_64; /* packets that are 64 bytes */ 225b9b17debSTimur Tabi u64 rx_sz_65_127; /* packets that are 65-127 bytes */ 226b9b17debSTimur Tabi u64 rx_sz_128_255; /* packets that are 128-255 bytes */ 227b9b17debSTimur Tabi u64 rx_sz_256_511; /* packets that are 256-511 bytes */ 228b9b17debSTimur Tabi u64 rx_sz_512_1023; /* packets that are 512-1023 bytes */ 229b9b17debSTimur Tabi u64 rx_sz_1024_1518; /* packets that are 1024-1518 bytes */ 230b9b17debSTimur Tabi u64 rx_sz_1519_max; /* packets that are 1519-MTU bytes*/ 231b9b17debSTimur Tabi u64 rx_sz_ov; /* packets that are >MTU bytes (truncated) */ 232b9b17debSTimur Tabi u64 rx_rxf_ov; /* packets dropped due to RX FIFO overflow */ 233b9b17debSTimur Tabi u64 rx_align_err; /* alignment errors */ 234b9b17debSTimur Tabi u64 rx_bcast_byte_cnt; /* broadcast packets byte count (without FCS) */ 235b9b17debSTimur Tabi u64 rx_mcast_byte_cnt; /* multicast packets byte count (without FCS) */ 236b9b17debSTimur Tabi u64 rx_err_addr; /* packets dropped due to address filtering */ 237b9b17debSTimur Tabi u64 rx_crc_align; /* CRC align errors */ 238b9b17debSTimur Tabi u64 rx_jabbers; /* jabbers */ 239b9b17debSTimur Tabi 240b9b17debSTimur Tabi /* tx */ 241b9b17debSTimur Tabi u64 tx_ok; /* good packets */ 242b9b17debSTimur Tabi u64 tx_bcast; /* good broadcast packets */ 243b9b17debSTimur Tabi u64 tx_mcast; /* good multicast packets */ 244b9b17debSTimur Tabi u64 tx_pause; /* pause packets */ 245b9b17debSTimur Tabi u64 tx_exc_defer; /* packets with excessive deferral */ 246b9b17debSTimur Tabi u64 tx_ctrl; /* control packets other than pause frame */ 247b9b17debSTimur Tabi u64 tx_defer; /* packets that are deferred. */ 248b9b17debSTimur Tabi u64 tx_byte_cnt; /* good bytes count (without FCS) */ 249b9b17debSTimur Tabi u64 tx_sz_64; /* packets that are 64 bytes */ 250b9b17debSTimur Tabi u64 tx_sz_65_127; /* packets that are 65-127 bytes */ 251b9b17debSTimur Tabi u64 tx_sz_128_255; /* packets that are 128-255 bytes */ 252b9b17debSTimur Tabi u64 tx_sz_256_511; /* packets that are 256-511 bytes */ 253b9b17debSTimur Tabi u64 tx_sz_512_1023; /* packets that are 512-1023 bytes */ 254b9b17debSTimur Tabi u64 tx_sz_1024_1518; /* packets that are 1024-1518 bytes */ 255b9b17debSTimur Tabi u64 tx_sz_1519_max; /* packets that are 1519-MTU bytes */ 256b9b17debSTimur Tabi u64 tx_1_col; /* packets single prior collision */ 257b9b17debSTimur Tabi u64 tx_2_col; /* packets with multiple prior collisions */ 258b9b17debSTimur Tabi u64 tx_late_col; /* packets with late collisions */ 259b9b17debSTimur Tabi u64 tx_abort_col; /* packets aborted due to excess collisions */ 260b9b17debSTimur Tabi u64 tx_underrun; /* packets aborted due to FIFO underrun */ 261b9b17debSTimur Tabi u64 tx_rd_eop; /* count of reads beyond EOP */ 262b9b17debSTimur Tabi u64 tx_len_err; /* packets with length mismatch */ 263b9b17debSTimur Tabi u64 tx_trunc; /* packets truncated due to size >MTU */ 264b9b17debSTimur Tabi u64 tx_bcast_byte; /* broadcast packets byte count (without FCS) */ 265b9b17debSTimur Tabi u64 tx_mcast_byte; /* multicast packets byte count (without FCS) */ 266b9b17debSTimur Tabi u64 tx_col; /* collisions */ 267b9b17debSTimur Tabi 268b9b17debSTimur Tabi spinlock_t lock; /* prevent multiple simultaneous readers */ 269b9b17debSTimur Tabi }; 270b9b17debSTimur Tabi 271b9b17debSTimur Tabi /* RSS hstype Definitions */ 272b9b17debSTimur Tabi #define EMAC_RSS_HSTYP_IPV4_EN 0x00000001 273b9b17debSTimur Tabi #define EMAC_RSS_HSTYP_TCP4_EN 0x00000002 274b9b17debSTimur Tabi #define EMAC_RSS_HSTYP_IPV6_EN 0x00000004 275b9b17debSTimur Tabi #define EMAC_RSS_HSTYP_TCP6_EN 0x00000008 276b9b17debSTimur Tabi #define EMAC_RSS_HSTYP_ALL_EN (\ 277b9b17debSTimur Tabi EMAC_RSS_HSTYP_IPV4_EN |\ 278b9b17debSTimur Tabi EMAC_RSS_HSTYP_TCP4_EN |\ 279b9b17debSTimur Tabi EMAC_RSS_HSTYP_IPV6_EN |\ 280b9b17debSTimur Tabi EMAC_RSS_HSTYP_TCP6_EN) 281b9b17debSTimur Tabi 282b9b17debSTimur Tabi #define EMAC_VLAN_TO_TAG(_vlan, _tag) \ 283b9b17debSTimur Tabi (_tag = ((((_vlan) >> 8) & 0xFF) | (((_vlan) & 0xFF) << 8))) 284b9b17debSTimur Tabi 285b9b17debSTimur Tabi #define EMAC_TAG_TO_VLAN(_tag, _vlan) \ 286b9b17debSTimur Tabi (_vlan = ((((_tag) >> 8) & 0xFF) | (((_tag) & 0xFF) << 8))) 287b9b17debSTimur Tabi 288b9b17debSTimur Tabi #define EMAC_DEF_RX_BUF_SIZE 1536 289b9b17debSTimur Tabi #define EMAC_MAX_JUMBO_PKT_SIZE (9 * 1024) 290b9b17debSTimur Tabi #define EMAC_MAX_TX_OFFLOAD_THRESH (9 * 1024) 291b9b17debSTimur Tabi 292b9b17debSTimur Tabi #define EMAC_MAX_ETH_FRAME_SIZE EMAC_MAX_JUMBO_PKT_SIZE 293b9b17debSTimur Tabi #define EMAC_MIN_ETH_FRAME_SIZE 68 294b9b17debSTimur Tabi 295b9b17debSTimur Tabi #define EMAC_DEF_TX_QUEUES 1 296b9b17debSTimur Tabi #define EMAC_DEF_RX_QUEUES 1 297b9b17debSTimur Tabi 298b9b17debSTimur Tabi #define EMAC_MIN_TX_DESCS 128 299b9b17debSTimur Tabi #define EMAC_MIN_RX_DESCS 128 300b9b17debSTimur Tabi 301b9b17debSTimur Tabi #define EMAC_MAX_TX_DESCS 16383 302b9b17debSTimur Tabi #define EMAC_MAX_RX_DESCS 2047 303b9b17debSTimur Tabi 304b9b17debSTimur Tabi #define EMAC_DEF_TX_DESCS 512 305b9b17debSTimur Tabi #define EMAC_DEF_RX_DESCS 256 306b9b17debSTimur Tabi 307b9b17debSTimur Tabi #define EMAC_DEF_RX_IRQ_MOD 250 308b9b17debSTimur Tabi #define EMAC_DEF_TX_IRQ_MOD 250 309b9b17debSTimur Tabi 310b9b17debSTimur Tabi #define EMAC_WATCHDOG_TIME (5 * HZ) 311b9b17debSTimur Tabi 312b9b17debSTimur Tabi /* by default check link every 4 seconds */ 313b9b17debSTimur Tabi #define EMAC_TRY_LINK_TIMEOUT (4 * HZ) 314b9b17debSTimur Tabi 315b9b17debSTimur Tabi /* emac_irq per-device (per-adapter) irq properties. 316b9b17debSTimur Tabi * @irq: irq number. 317b9b17debSTimur Tabi * @mask mask to use over status register. 318b9b17debSTimur Tabi */ 319b9b17debSTimur Tabi struct emac_irq { 320b9b17debSTimur Tabi unsigned int irq; 321b9b17debSTimur Tabi u32 mask; 322b9b17debSTimur Tabi }; 323b9b17debSTimur Tabi 324b9b17debSTimur Tabi /* The device's main data structure */ 325b9b17debSTimur Tabi struct emac_adapter { 326b9b17debSTimur Tabi struct net_device *netdev; 327b9b17debSTimur Tabi struct mii_bus *mii_bus; 328b9b17debSTimur Tabi struct phy_device *phydev; 329b9b17debSTimur Tabi 330b9b17debSTimur Tabi void __iomem *base; 331b9b17debSTimur Tabi void __iomem *csr; 332b9b17debSTimur Tabi 33341c1093fSTimur Tabi struct emac_sgmii phy; 334b9b17debSTimur Tabi struct emac_stats stats; 335b9b17debSTimur Tabi 336b9b17debSTimur Tabi struct emac_irq irq; 337b9b17debSTimur Tabi struct clk *clk[EMAC_CLK_CNT]; 338b9b17debSTimur Tabi 339b9b17debSTimur Tabi /* All Descriptor memory */ 340b9b17debSTimur Tabi struct emac_ring_header ring_header; 341b9b17debSTimur Tabi struct emac_tx_queue tx_q; 342b9b17debSTimur Tabi struct emac_rx_queue rx_q; 343b9b17debSTimur Tabi unsigned int tx_desc_cnt; 344b9b17debSTimur Tabi unsigned int rx_desc_cnt; 345b9b17debSTimur Tabi unsigned int rrd_size; /* in quad words */ 346b9b17debSTimur Tabi unsigned int rfd_size; /* in quad words */ 347b9b17debSTimur Tabi unsigned int tpd_size; /* in quad words */ 348b9b17debSTimur Tabi 349b9b17debSTimur Tabi unsigned int rxbuf_size; 350b9b17debSTimur Tabi 351b44700e9STimur Tabi /* Flow control / pause frames support. If automatic=True, do whatever 352b44700e9STimur Tabi * the PHY does. Otherwise, use tx_flow_control and rx_flow_control. 353b44700e9STimur Tabi */ 354b44700e9STimur Tabi bool automatic; 355b44700e9STimur Tabi bool tx_flow_control; 356b44700e9STimur Tabi bool rx_flow_control; 357b44700e9STimur Tabi 3584a7a3860STimur Tabi /* True == use single-pause-frame mode. */ 3594a7a3860STimur Tabi bool single_pause_mode; 3604a7a3860STimur Tabi 361b9b17debSTimur Tabi /* Ring parameter */ 362b9b17debSTimur Tabi u8 tpd_burst; 363b9b17debSTimur Tabi u8 rfd_burst; 364b9b17debSTimur Tabi unsigned int dmaw_dly_cnt; 365b9b17debSTimur Tabi unsigned int dmar_dly_cnt; 366b9b17debSTimur Tabi enum emac_dma_req_block dmar_block; 367b9b17debSTimur Tabi enum emac_dma_req_block dmaw_block; 368b9b17debSTimur Tabi enum emac_dma_order dma_order; 369b9b17debSTimur Tabi 370b9b17debSTimur Tabi u32 irq_mod; 371b9b17debSTimur Tabi u32 preamble; 372b9b17debSTimur Tabi 373b9b17debSTimur Tabi struct work_struct work_thread; 374b9b17debSTimur Tabi 375b9b17debSTimur Tabi u16 msg_enable; 376b9b17debSTimur Tabi 377b9b17debSTimur Tabi struct mutex reset_lock; 378b9b17debSTimur Tabi }; 379b9b17debSTimur Tabi 380b9b17debSTimur Tabi int emac_reinit_locked(struct emac_adapter *adpt); 381b9b17debSTimur Tabi void emac_reg_update32(void __iomem *addr, u32 mask, u32 val); 382b9b17debSTimur Tabi 38379f664edSTimur Tabi void emac_set_ethtool_ops(struct net_device *netdev); 38479f664edSTimur Tabi void emac_update_hw_stats(struct emac_adapter *adpt); 38579f664edSTimur Tabi 386b9b17debSTimur Tabi #endif /* _EMAC_H_ */ 387