183d290c5STom Rini /* SPDX-License-Identifier: GPL-2.0+ */ 29b6bcdcbSAlbert Aribaud /* 39b6bcdcbSAlbert Aribaud * (C) Copyright 2009 49b6bcdcbSAlbert Aribaud * Marvell Semiconductor <www.marvell.com> 59b6bcdcbSAlbert Aribaud * Written-by: Prafulla Wadaskar <prafulla@marvell.com> 69b6bcdcbSAlbert Aribaud * 79b6bcdcbSAlbert Aribaud * based on - Driver for MV64360X ethernet ports 89b6bcdcbSAlbert Aribaud * Copyright (C) 2002 rabeeh@galileo.co.il 99b6bcdcbSAlbert Aribaud */ 109b6bcdcbSAlbert Aribaud 11d44265adSAlbert Aribaud #ifndef __MVGBE_H__ 12d44265adSAlbert Aribaud #define __MVGBE_H__ 139b6bcdcbSAlbert Aribaud 149b6bcdcbSAlbert Aribaud /* PHY_BASE_ADR is board specific and can be configured */ 159b6bcdcbSAlbert Aribaud #if defined (CONFIG_PHY_BASE_ADR) 169b6bcdcbSAlbert Aribaud #define PHY_BASE_ADR CONFIG_PHY_BASE_ADR 179b6bcdcbSAlbert Aribaud #else 189b6bcdcbSAlbert Aribaud #define PHY_BASE_ADR 0x08 /* default phy base addr */ 199b6bcdcbSAlbert Aribaud #endif 209b6bcdcbSAlbert Aribaud 219b6bcdcbSAlbert Aribaud /* Constants */ 229b6bcdcbSAlbert Aribaud #define INT_CAUSE_UNMASK_ALL 0x0007ffff 239b6bcdcbSAlbert Aribaud #define INT_CAUSE_UNMASK_ALL_EXT 0x0011ffff 249b6bcdcbSAlbert Aribaud #define MRU_MASK 0xfff1ffff 259b6bcdcbSAlbert Aribaud #define PHYADR_MASK 0x0000001f 269b6bcdcbSAlbert Aribaud #define PHYREG_MASK 0x0000001f 279b6bcdcbSAlbert Aribaud #define QTKNBKT_DEF_VAL 0x3fffffff 289b6bcdcbSAlbert Aribaud #define QMTBS_DEF_VAL 0x000003ff 299b6bcdcbSAlbert Aribaud #define QTKNRT_DEF_VAL 0x0000fcff 309b6bcdcbSAlbert Aribaud #define RXUQ 0 /* Used Rx queue */ 319b6bcdcbSAlbert Aribaud #define TXUQ 0 /* Used Rx queue */ 329b6bcdcbSAlbert Aribaud 33*fb731076SChris Packham #ifndef CONFIG_DM_ETH 34d44265adSAlbert Aribaud #define to_mvgbe(_d) container_of(_d, struct mvgbe_device, dev) 35*fb731076SChris Packham #endif 36d44265adSAlbert Aribaud #define MVGBE_REG_WR(adr, val) writel(val, &adr) 37d44265adSAlbert Aribaud #define MVGBE_REG_RD(adr) readl(&adr) 38d44265adSAlbert Aribaud #define MVGBE_REG_BITS_RESET(adr, val) writel(readl(&adr) & ~(val), &adr) 39d44265adSAlbert Aribaud #define MVGBE_REG_BITS_SET(adr, val) writel(readl(&adr) | val, &adr) 409b6bcdcbSAlbert Aribaud 419b6bcdcbSAlbert Aribaud /* Default port configuration value */ 429b6bcdcbSAlbert Aribaud #define PRT_CFG_VAL ( \ 43d44265adSAlbert Aribaud MVGBE_UCAST_MOD_NRML | \ 44d44265adSAlbert Aribaud MVGBE_DFLT_RXQ(RXUQ) | \ 45d44265adSAlbert Aribaud MVGBE_DFLT_RX_ARPQ(RXUQ) | \ 46d44265adSAlbert Aribaud MVGBE_RX_BC_IF_NOT_IP_OR_ARP | \ 47d44265adSAlbert Aribaud MVGBE_RX_BC_IF_IP | \ 48d44265adSAlbert Aribaud MVGBE_RX_BC_IF_ARP | \ 49d44265adSAlbert Aribaud MVGBE_CPTR_TCP_FRMS_DIS | \ 50d44265adSAlbert Aribaud MVGBE_CPTR_UDP_FRMS_DIS | \ 51d44265adSAlbert Aribaud MVGBE_DFLT_RX_TCPQ(RXUQ) | \ 52d44265adSAlbert Aribaud MVGBE_DFLT_RX_UDPQ(RXUQ) | \ 53d44265adSAlbert Aribaud MVGBE_DFLT_RX_BPDUQ(RXUQ)) 549b6bcdcbSAlbert Aribaud 559b6bcdcbSAlbert Aribaud /* Default port extend configuration value */ 569b6bcdcbSAlbert Aribaud #define PORT_CFG_EXTEND_VALUE \ 57d44265adSAlbert Aribaud MVGBE_SPAN_BPDU_PACKETS_AS_NORMAL | \ 58d44265adSAlbert Aribaud MVGBE_PARTITION_DIS | \ 59d44265adSAlbert Aribaud MVGBE_TX_CRC_GENERATION_EN 609b6bcdcbSAlbert Aribaud 61d44265adSAlbert Aribaud #define GT_MVGBE_IPG_INT_RX(value) ((value & 0x3fff) << 8) 629b6bcdcbSAlbert Aribaud 639b6bcdcbSAlbert Aribaud /* Default sdma control value */ 649b6bcdcbSAlbert Aribaud #define PORT_SDMA_CFG_VALUE ( \ 65d44265adSAlbert Aribaud MVGBE_RX_BURST_SIZE_16_64BIT | \ 66d44265adSAlbert Aribaud MVGBE_BLM_RX_NO_SWAP | \ 67d44265adSAlbert Aribaud MVGBE_BLM_TX_NO_SWAP | \ 68d44265adSAlbert Aribaud GT_MVGBE_IPG_INT_RX(RXUQ) | \ 69d44265adSAlbert Aribaud MVGBE_TX_BURST_SIZE_16_64BIT) 709b6bcdcbSAlbert Aribaud 719b6bcdcbSAlbert Aribaud /* Default port serial control value */ 72d3920144SValentin Longchamp #ifndef PORT_SERIAL_CONTROL_VALUE 739b6bcdcbSAlbert Aribaud #define PORT_SERIAL_CONTROL_VALUE ( \ 74d44265adSAlbert Aribaud MVGBE_FORCE_LINK_PASS | \ 75d44265adSAlbert Aribaud MVGBE_DIS_AUTO_NEG_FOR_DUPLX | \ 76d44265adSAlbert Aribaud MVGBE_DIS_AUTO_NEG_FOR_FLOW_CTRL | \ 77d44265adSAlbert Aribaud MVGBE_ADV_NO_FLOW_CTRL | \ 78d44265adSAlbert Aribaud MVGBE_FORCE_FC_MODE_NO_PAUSE_DIS_TX | \ 79d44265adSAlbert Aribaud MVGBE_FORCE_BP_MODE_NO_JAM | \ 809b6bcdcbSAlbert Aribaud (1 << 9) /* Reserved bit has to be 1 */ | \ 81d44265adSAlbert Aribaud MVGBE_DO_NOT_FORCE_LINK_FAIL | \ 82d44265adSAlbert Aribaud MVGBE_EN_AUTO_NEG_SPEED_GMII | \ 83d44265adSAlbert Aribaud MVGBE_DTE_ADV_0 | \ 84d44265adSAlbert Aribaud MVGBE_MIIPHY_MAC_MODE | \ 85d44265adSAlbert Aribaud MVGBE_AUTO_NEG_NO_CHANGE | \ 86d44265adSAlbert Aribaud MVGBE_MAX_RX_PACKET_1552BYTE | \ 87d44265adSAlbert Aribaud MVGBE_CLR_EXT_LOOPBACK | \ 88d44265adSAlbert Aribaud MVGBE_SET_FULL_DUPLEX_MODE | \ 89d44265adSAlbert Aribaud MVGBE_DIS_FLOW_CTRL_TX_RX_IN_FULL_DUPLEX) 90d3920144SValentin Longchamp #endif 919b6bcdcbSAlbert Aribaud 929b6bcdcbSAlbert Aribaud /* Tx WRR confoguration macros */ 939b6bcdcbSAlbert Aribaud #define PORT_MAX_TRAN_UNIT 0x24 /* MTU register (default) 9KByte */ 949b6bcdcbSAlbert Aribaud #define PORT_MAX_TOKEN_BUCKET_SIZE 0x_FFFF /* PMTBS reg (default) */ 959b6bcdcbSAlbert Aribaud #define PORT_TOKEN_RATE 1023 /* PTTBRC reg (default) */ 969b6bcdcbSAlbert Aribaud /* MAC accepet/reject macros */ 979b6bcdcbSAlbert Aribaud #define ACCEPT_MAC_ADDR 0 989b6bcdcbSAlbert Aribaud #define REJECT_MAC_ADDR 1 999b6bcdcbSAlbert Aribaud /* Size of a Tx/Rx descriptor used in chain list data structure */ 100d44265adSAlbert Aribaud #define MV_RXQ_DESC_ALIGNED_SIZE \ 101d44265adSAlbert Aribaud (((sizeof(struct mvgbe_rxdesc) / PKTALIGN) + 1) * PKTALIGN) 1029b6bcdcbSAlbert Aribaud /* Buffer offset from buffer pointer */ 1039b6bcdcbSAlbert Aribaud #define RX_BUF_OFFSET 0x2 1049b6bcdcbSAlbert Aribaud 1059b6bcdcbSAlbert Aribaud /* Port serial status reg (PSR) */ 106d44265adSAlbert Aribaud #define MVGBE_INTERFACE_GMII_MII 0 107d44265adSAlbert Aribaud #define MVGBE_INTERFACE_PCM 1 108d44265adSAlbert Aribaud #define MVGBE_LINK_IS_DOWN 0 109d44265adSAlbert Aribaud #define MVGBE_LINK_IS_UP (1 << 1) 110d44265adSAlbert Aribaud #define MVGBE_PORT_AT_HALF_DUPLEX 0 111d44265adSAlbert Aribaud #define MVGBE_PORT_AT_FULL_DUPLEX (1 << 2) 112d44265adSAlbert Aribaud #define MVGBE_RX_FLOW_CTRL_DISD 0 113d44265adSAlbert Aribaud #define MVGBE_RX_FLOW_CTRL_ENBALED (1 << 3) 114d44265adSAlbert Aribaud #define MVGBE_GMII_SPEED_100_10 0 115d44265adSAlbert Aribaud #define MVGBE_GMII_SPEED_1000 (1 << 4) 116d44265adSAlbert Aribaud #define MVGBE_MII_SPEED_10 0 117d44265adSAlbert Aribaud #define MVGBE_MII_SPEED_100 (1 << 5) 118d44265adSAlbert Aribaud #define MVGBE_NO_TX 0 119d44265adSAlbert Aribaud #define MVGBE_TX_IN_PROGRESS (1 << 7) 120d44265adSAlbert Aribaud #define MVGBE_BYPASS_NO_ACTIVE 0 121d44265adSAlbert Aribaud #define MVGBE_BYPASS_ACTIVE (1 << 8) 122d44265adSAlbert Aribaud #define MVGBE_PORT_NOT_AT_PARTN_STT 0 123d44265adSAlbert Aribaud #define MVGBE_PORT_AT_PARTN_STT (1 << 9) 124d44265adSAlbert Aribaud #define MVGBE_PORT_TX_FIFO_NOT_EMPTY 0 125d44265adSAlbert Aribaud #define MVGBE_PORT_TX_FIFO_EMPTY (1 << 10) 1269b6bcdcbSAlbert Aribaud 1279b6bcdcbSAlbert Aribaud /* These macros describes the Port configuration reg (Px_cR) bits */ 128d44265adSAlbert Aribaud #define MVGBE_UCAST_MOD_NRML 0 129d44265adSAlbert Aribaud #define MVGBE_UNICAST_PROMISCUOUS_MODE 1 130d44265adSAlbert Aribaud #define MVGBE_DFLT_RXQ(_x) (_x << 1) 131d44265adSAlbert Aribaud #define MVGBE_DFLT_RX_ARPQ(_x) (_x << 4) 132d44265adSAlbert Aribaud #define MVGBE_RX_BC_IF_NOT_IP_OR_ARP 0 133d44265adSAlbert Aribaud #define MVGBE_REJECT_BC_IF_NOT_IP_OR_ARP (1 << 7) 134d44265adSAlbert Aribaud #define MVGBE_RX_BC_IF_IP 0 135d44265adSAlbert Aribaud #define MVGBE_REJECT_BC_IF_IP (1 << 8) 136d44265adSAlbert Aribaud #define MVGBE_RX_BC_IF_ARP 0 137d44265adSAlbert Aribaud #define MVGBE_REJECT_BC_IF_ARP (1 << 9) 138d44265adSAlbert Aribaud #define MVGBE_TX_AM_NO_UPDATE_ERR_SMRY (1 << 12) 139d44265adSAlbert Aribaud #define MVGBE_CPTR_TCP_FRMS_DIS 0 140d44265adSAlbert Aribaud #define MVGBE_CPTR_TCP_FRMS_EN (1 << 14) 141d44265adSAlbert Aribaud #define MVGBE_CPTR_UDP_FRMS_DIS 0 142d44265adSAlbert Aribaud #define MVGBE_CPTR_UDP_FRMS_EN (1 << 15) 143d44265adSAlbert Aribaud #define MVGBE_DFLT_RX_TCPQ(_x) (_x << 16) 144d44265adSAlbert Aribaud #define MVGBE_DFLT_RX_UDPQ(_x) (_x << 19) 145d44265adSAlbert Aribaud #define MVGBE_DFLT_RX_BPDUQ(_x) (_x << 22) 146d44265adSAlbert Aribaud #define MVGBE_DFLT_RX_TCP_CHKSUM_MODE (1 << 25) 1479b6bcdcbSAlbert Aribaud 1489b6bcdcbSAlbert Aribaud /* These macros describes the Port configuration extend reg (Px_cXR) bits*/ 149d44265adSAlbert Aribaud #define MVGBE_CLASSIFY_EN 1 150d44265adSAlbert Aribaud #define MVGBE_SPAN_BPDU_PACKETS_AS_NORMAL 0 151d44265adSAlbert Aribaud #define MVGBE_SPAN_BPDU_PACKETS_TO_RX_Q7 (1 << 1) 152d44265adSAlbert Aribaud #define MVGBE_PARTITION_DIS 0 153d44265adSAlbert Aribaud #define MVGBE_PARTITION_EN (1 << 2) 154d44265adSAlbert Aribaud #define MVGBE_TX_CRC_GENERATION_EN 0 155d44265adSAlbert Aribaud #define MVGBE_TX_CRC_GENERATION_DIS (1 << 3) 1569b6bcdcbSAlbert Aribaud 1579b6bcdcbSAlbert Aribaud /* These macros describes the Port Sdma configuration reg (SDCR) bits */ 158d44265adSAlbert Aribaud #define MVGBE_RIFB 1 159d44265adSAlbert Aribaud #define MVGBE_RX_BURST_SIZE_1_64BIT 0 160d44265adSAlbert Aribaud #define MVGBE_RX_BURST_SIZE_2_64BIT (1 << 1) 161d44265adSAlbert Aribaud #define MVGBE_RX_BURST_SIZE_4_64BIT (1 << 2) 162d44265adSAlbert Aribaud #define MVGBE_RX_BURST_SIZE_8_64BIT ((1 << 2) | (1 << 1)) 163d44265adSAlbert Aribaud #define MVGBE_RX_BURST_SIZE_16_64BIT (1 << 3) 164d44265adSAlbert Aribaud #define MVGBE_BLM_RX_NO_SWAP (1 << 4) 165d44265adSAlbert Aribaud #define MVGBE_BLM_RX_BYTE_SWAP 0 166d44265adSAlbert Aribaud #define MVGBE_BLM_TX_NO_SWAP (1 << 5) 167d44265adSAlbert Aribaud #define MVGBE_BLM_TX_BYTE_SWAP 0 168d44265adSAlbert Aribaud #define MVGBE_DESCRIPTORS_BYTE_SWAP (1 << 6) 169d44265adSAlbert Aribaud #define MVGBE_DESCRIPTORS_NO_SWAP 0 170d44265adSAlbert Aribaud #define MVGBE_TX_BURST_SIZE_1_64BIT 0 171d44265adSAlbert Aribaud #define MVGBE_TX_BURST_SIZE_2_64BIT (1 << 22) 172d44265adSAlbert Aribaud #define MVGBE_TX_BURST_SIZE_4_64BIT (1 << 23) 173d44265adSAlbert Aribaud #define MVGBE_TX_BURST_SIZE_8_64BIT ((1 << 23) | (1 << 22)) 174d44265adSAlbert Aribaud #define MVGBE_TX_BURST_SIZE_16_64BIT (1 << 24) 1759b6bcdcbSAlbert Aribaud 1769b6bcdcbSAlbert Aribaud /* These macros describes the Port serial control reg (PSCR) bits */ 177d44265adSAlbert Aribaud #define MVGBE_SERIAL_PORT_DIS 0 178d44265adSAlbert Aribaud #define MVGBE_SERIAL_PORT_EN 1 179d44265adSAlbert Aribaud #define MVGBE_FORCE_LINK_PASS (1 << 1) 180d44265adSAlbert Aribaud #define MVGBE_DO_NOT_FORCE_LINK_PASS 0 181d44265adSAlbert Aribaud #define MVGBE_EN_AUTO_NEG_FOR_DUPLX 0 182d44265adSAlbert Aribaud #define MVGBE_DIS_AUTO_NEG_FOR_DUPLX (1 << 2) 183d44265adSAlbert Aribaud #define MVGBE_EN_AUTO_NEG_FOR_FLOW_CTRL 0 184d44265adSAlbert Aribaud #define MVGBE_DIS_AUTO_NEG_FOR_FLOW_CTRL (1 << 3) 185d44265adSAlbert Aribaud #define MVGBE_ADV_NO_FLOW_CTRL 0 186d44265adSAlbert Aribaud #define MVGBE_ADV_SYMMETRIC_FLOW_CTRL (1 << 4) 187d44265adSAlbert Aribaud #define MVGBE_FORCE_FC_MODE_NO_PAUSE_DIS_TX 0 188d44265adSAlbert Aribaud #define MVGBE_FORCE_FC_MODE_TX_PAUSE_DIS (1 << 5) 189d44265adSAlbert Aribaud #define MVGBE_FORCE_BP_MODE_NO_JAM 0 190d44265adSAlbert Aribaud #define MVGBE_FORCE_BP_MODE_JAM_TX (1 << 7) 191d44265adSAlbert Aribaud #define MVGBE_FORCE_BP_MODE_JAM_TX_ON_RX_ERR (1 << 8) 192d44265adSAlbert Aribaud #define MVGBE_FORCE_LINK_FAIL 0 193d44265adSAlbert Aribaud #define MVGBE_DO_NOT_FORCE_LINK_FAIL (1 << 10) 194d44265adSAlbert Aribaud #define MVGBE_DIS_AUTO_NEG_SPEED_GMII (1 << 13) 195d44265adSAlbert Aribaud #define MVGBE_EN_AUTO_NEG_SPEED_GMII 0 196d44265adSAlbert Aribaud #define MVGBE_DTE_ADV_0 0 197d44265adSAlbert Aribaud #define MVGBE_DTE_ADV_1 (1 << 14) 198d44265adSAlbert Aribaud #define MVGBE_MIIPHY_MAC_MODE 0 199d44265adSAlbert Aribaud #define MVGBE_MIIPHY_PHY_MODE (1 << 15) 200d44265adSAlbert Aribaud #define MVGBE_AUTO_NEG_NO_CHANGE 0 201d44265adSAlbert Aribaud #define MVGBE_RESTART_AUTO_NEG (1 << 16) 202d44265adSAlbert Aribaud #define MVGBE_MAX_RX_PACKET_1518BYTE 0 203d44265adSAlbert Aribaud #define MVGBE_MAX_RX_PACKET_1522BYTE (1 << 17) 204d44265adSAlbert Aribaud #define MVGBE_MAX_RX_PACKET_1552BYTE (1 << 18) 205d44265adSAlbert Aribaud #define MVGBE_MAX_RX_PACKET_9022BYTE ((1 << 18) | (1 << 17)) 206d44265adSAlbert Aribaud #define MVGBE_MAX_RX_PACKET_9192BYTE (1 << 19) 207d44265adSAlbert Aribaud #define MVGBE_MAX_RX_PACKET_9700BYTE ((1 << 19) | (1 << 17)) 208d44265adSAlbert Aribaud #define MVGBE_SET_EXT_LOOPBACK (1 << 20) 209d44265adSAlbert Aribaud #define MVGBE_CLR_EXT_LOOPBACK 0 210d44265adSAlbert Aribaud #define MVGBE_SET_FULL_DUPLEX_MODE (1 << 21) 211d44265adSAlbert Aribaud #define MVGBE_SET_HALF_DUPLEX_MODE 0 212d44265adSAlbert Aribaud #define MVGBE_EN_FLOW_CTRL_TX_RX_IN_FULL_DUPLEX (1 << 22) 213d44265adSAlbert Aribaud #define MVGBE_DIS_FLOW_CTRL_TX_RX_IN_FULL_DUPLEX 0 214d44265adSAlbert Aribaud #define MVGBE_SET_GMII_SPEED_TO_10_100 0 215d44265adSAlbert Aribaud #define MVGBE_SET_GMII_SPEED_TO_1000 (1 << 23) 216d44265adSAlbert Aribaud #define MVGBE_SET_MII_SPEED_TO_10 0 217d44265adSAlbert Aribaud #define MVGBE_SET_MII_SPEED_TO_100 (1 << 24) 2189b6bcdcbSAlbert Aribaud 2199b6bcdcbSAlbert Aribaud /* SMI register fields */ 220d44265adSAlbert Aribaud #define MVGBE_PHY_SMI_TIMEOUT 10000 2215194ed7eSChris Packham #define MVGBE_PHY_SMI_TIMEOUT_MS 1000 222d44265adSAlbert Aribaud #define MVGBE_PHY_SMI_DATA_OFFS 0 /* Data */ 223d44265adSAlbert Aribaud #define MVGBE_PHY_SMI_DATA_MASK (0xffff << MVGBE_PHY_SMI_DATA_OFFS) 224d44265adSAlbert Aribaud #define MVGBE_PHY_SMI_DEV_ADDR_OFFS 16 /* PHY device address */ 225d44265adSAlbert Aribaud #define MVGBE_PHY_SMI_DEV_ADDR_MASK \ 226d44265adSAlbert Aribaud (PHYADR_MASK << MVGBE_PHY_SMI_DEV_ADDR_OFFS) 227d44265adSAlbert Aribaud #define MVGBE_SMI_REG_ADDR_OFFS 21 /* PHY device reg addr */ 228d44265adSAlbert Aribaud #define MVGBE_SMI_REG_ADDR_MASK \ 229d44265adSAlbert Aribaud (PHYADR_MASK << MVGBE_SMI_REG_ADDR_OFFS) 230d44265adSAlbert Aribaud #define MVGBE_PHY_SMI_OPCODE_OFFS 26 /* Write/Read opcode */ 231d44265adSAlbert Aribaud #define MVGBE_PHY_SMI_OPCODE_MASK (3 << MVGBE_PHY_SMI_OPCODE_OFFS) 232d44265adSAlbert Aribaud #define MVGBE_PHY_SMI_OPCODE_WRITE (0 << MVGBE_PHY_SMI_OPCODE_OFFS) 233d44265adSAlbert Aribaud #define MVGBE_PHY_SMI_OPCODE_READ (1 << MVGBE_PHY_SMI_OPCODE_OFFS) 234d44265adSAlbert Aribaud #define MVGBE_PHY_SMI_READ_VALID_MASK (1 << 27) /* Read Valid */ 235d44265adSAlbert Aribaud #define MVGBE_PHY_SMI_BUSY_MASK (1 << 28) /* Busy */ 2369b6bcdcbSAlbert Aribaud 2379b6bcdcbSAlbert Aribaud /* SDMA command status fields macros */ 2389b6bcdcbSAlbert Aribaud /* Tx & Rx descriptors status */ 239d44265adSAlbert Aribaud #define MVGBE_ERROR_SUMMARY 1 2409b6bcdcbSAlbert Aribaud /* Tx & Rx descriptors command */ 241d44265adSAlbert Aribaud #define MVGBE_BUFFER_OWNED_BY_DMA (1 << 31) 2429b6bcdcbSAlbert Aribaud /* Tx descriptors status */ 243d44265adSAlbert Aribaud #define MVGBE_LC_ERROR 0 244d44265adSAlbert Aribaud #define MVGBE_UR_ERROR (1 << 1) 245d44265adSAlbert Aribaud #define MVGBE_RL_ERROR (1 << 2) 246d44265adSAlbert Aribaud #define MVGBE_LLC_SNAP_FORMAT (1 << 9) 247d44265adSAlbert Aribaud #define MVGBE_TX_LAST_FRAME (1 << 20) 2489b6bcdcbSAlbert Aribaud 2499b6bcdcbSAlbert Aribaud /* Rx descriptors status */ 250d44265adSAlbert Aribaud #define MVGBE_CRC_ERROR 0 251d44265adSAlbert Aribaud #define MVGBE_OVERRUN_ERROR (1 << 1) 252d44265adSAlbert Aribaud #define MVGBE_MAX_FRAME_LENGTH_ERROR (1 << 2) 253d44265adSAlbert Aribaud #define MVGBE_RESOURCE_ERROR ((1 << 2) | (1 << 1)) 254d44265adSAlbert Aribaud #define MVGBE_VLAN_TAGGED (1 << 19) 255d44265adSAlbert Aribaud #define MVGBE_BPDU_FRAME (1 << 20) 256d44265adSAlbert Aribaud #define MVGBE_TCP_FRAME_OVER_IP_V_4 0 257d44265adSAlbert Aribaud #define MVGBE_UDP_FRAME_OVER_IP_V_4 (1 << 21) 258d44265adSAlbert Aribaud #define MVGBE_OTHER_FRAME_TYPE (1 << 22) 259d44265adSAlbert Aribaud #define MVGBE_LAYER_2_IS_MVGBE_V_2 (1 << 23) 260d44265adSAlbert Aribaud #define MVGBE_FRAME_TYPE_IP_V_4 (1 << 24) 261d44265adSAlbert Aribaud #define MVGBE_FRAME_HEADER_OK (1 << 25) 262d44265adSAlbert Aribaud #define MVGBE_RX_LAST_DESC (1 << 26) 263d44265adSAlbert Aribaud #define MVGBE_RX_FIRST_DESC (1 << 27) 264d44265adSAlbert Aribaud #define MVGBE_UNKNOWN_DESTINATION_ADDR (1 << 28) 265d44265adSAlbert Aribaud #define MVGBE_RX_EN_INTERRUPT (1 << 29) 266d44265adSAlbert Aribaud #define MVGBE_LAYER_4_CHECKSUM_OK (1 << 30) 2679b6bcdcbSAlbert Aribaud 2689b6bcdcbSAlbert Aribaud /* Rx descriptors byte count */ 269d44265adSAlbert Aribaud #define MVGBE_FRAME_FRAGMENTED (1 << 2) 2709b6bcdcbSAlbert Aribaud 2719b6bcdcbSAlbert Aribaud /* Tx descriptors command */ 272d44265adSAlbert Aribaud #define MVGBE_LAYER_4_CHECKSUM_FIRST_DESC (1 << 10) 273d44265adSAlbert Aribaud #define MVGBE_FRAME_SET_TO_VLAN (1 << 15) 274d44265adSAlbert Aribaud #define MVGBE_TCP_FRAME 0 275d44265adSAlbert Aribaud #define MVGBE_UDP_FRAME (1 << 16) 276d44265adSAlbert Aribaud #define MVGBE_GEN_TCP_UDP_CHECKSUM (1 << 17) 277d44265adSAlbert Aribaud #define MVGBE_GEN_IP_V_4_CHECKSUM (1 << 18) 278d44265adSAlbert Aribaud #define MVGBE_ZERO_PADDING (1 << 19) 279d44265adSAlbert Aribaud #define MVGBE_TX_LAST_DESC (1 << 20) 280d44265adSAlbert Aribaud #define MVGBE_TX_FIRST_DESC (1 << 21) 281d44265adSAlbert Aribaud #define MVGBE_GEN_CRC (1 << 22) 282d44265adSAlbert Aribaud #define MVGBE_TX_EN_INTERRUPT (1 << 23) 283d44265adSAlbert Aribaud #define MVGBE_AUTO_MODE (1 << 30) 2849b6bcdcbSAlbert Aribaud 2859b6bcdcbSAlbert Aribaud /* Address decode parameters */ 2869b6bcdcbSAlbert Aribaud /* Ethernet Base Address Register bits */ 2879b6bcdcbSAlbert Aribaud #define EBAR_TARGET_DRAM 0x00000000 2889b6bcdcbSAlbert Aribaud #define EBAR_TARGET_DEVICE 0x00000001 2899b6bcdcbSAlbert Aribaud #define EBAR_TARGET_CBS 0x00000002 2909b6bcdcbSAlbert Aribaud #define EBAR_TARGET_PCI0 0x00000003 2919b6bcdcbSAlbert Aribaud #define EBAR_TARGET_PCI1 0x00000004 2929b6bcdcbSAlbert Aribaud #define EBAR_TARGET_CUNIT 0x00000005 2939b6bcdcbSAlbert Aribaud #define EBAR_TARGET_AUNIT 0x00000006 2949b6bcdcbSAlbert Aribaud #define EBAR_TARGET_GUNIT 0x00000007 2959b6bcdcbSAlbert Aribaud 2969b6bcdcbSAlbert Aribaud /* Window attrib */ 2979b6bcdcbSAlbert Aribaud #define EBAR_DRAM_CS0 0x00000E00 2989b6bcdcbSAlbert Aribaud #define EBAR_DRAM_CS1 0x00000D00 2999b6bcdcbSAlbert Aribaud #define EBAR_DRAM_CS2 0x00000B00 3009b6bcdcbSAlbert Aribaud #define EBAR_DRAM_CS3 0x00000700 3019b6bcdcbSAlbert Aribaud 3029b6bcdcbSAlbert Aribaud /* DRAM Target interface */ 3039b6bcdcbSAlbert Aribaud #define EBAR_DRAM_NO_CACHE_COHERENCY 0x00000000 3049b6bcdcbSAlbert Aribaud #define EBAR_DRAM_CACHE_COHERENCY_WT 0x00001000 3059b6bcdcbSAlbert Aribaud #define EBAR_DRAM_CACHE_COHERENCY_WB 0x00002000 3069b6bcdcbSAlbert Aribaud 3079b6bcdcbSAlbert Aribaud /* Device Bus Target interface */ 3089b6bcdcbSAlbert Aribaud #define EBAR_DEVICE_DEVCS0 0x00001E00 3099b6bcdcbSAlbert Aribaud #define EBAR_DEVICE_DEVCS1 0x00001D00 3109b6bcdcbSAlbert Aribaud #define EBAR_DEVICE_DEVCS2 0x00001B00 3119b6bcdcbSAlbert Aribaud #define EBAR_DEVICE_DEVCS3 0x00001700 3129b6bcdcbSAlbert Aribaud #define EBAR_DEVICE_BOOTCS3 0x00000F00 3139b6bcdcbSAlbert Aribaud 3149b6bcdcbSAlbert Aribaud /* PCI Target interface */ 3159b6bcdcbSAlbert Aribaud #define EBAR_PCI_BYTE_SWAP 0x00000000 3169b6bcdcbSAlbert Aribaud #define EBAR_PCI_NO_SWAP 0x00000100 3179b6bcdcbSAlbert Aribaud #define EBAR_PCI_BYTE_WORD_SWAP 0x00000200 3189b6bcdcbSAlbert Aribaud #define EBAR_PCI_WORD_SWAP 0x00000300 3199b6bcdcbSAlbert Aribaud #define EBAR_PCI_NO_SNOOP_NOT_ASSERT 0x00000000 3209b6bcdcbSAlbert Aribaud #define EBAR_PCI_NO_SNOOP_ASSERT 0x00000400 3219b6bcdcbSAlbert Aribaud #define EBAR_PCI_IO_SPACE 0x00000000 3229b6bcdcbSAlbert Aribaud #define EBAR_PCI_MEMORY_SPACE 0x00000800 3239b6bcdcbSAlbert Aribaud #define EBAR_PCI_REQ64_FORCE 0x00000000 3249b6bcdcbSAlbert Aribaud #define EBAR_PCI_REQ64_SIZE 0x00001000 3259b6bcdcbSAlbert Aribaud 3269b6bcdcbSAlbert Aribaud /* Window access control */ 3279b6bcdcbSAlbert Aribaud #define EWIN_ACCESS_NOT_ALLOWED 0 3289b6bcdcbSAlbert Aribaud #define EWIN_ACCESS_READ_ONLY 1 3299b6bcdcbSAlbert Aribaud #define EWIN_ACCESS_FULL ((1 << 1) | 1) 3309b6bcdcbSAlbert Aribaud 3319b6bcdcbSAlbert Aribaud /* structures represents Controller registers */ 332d44265adSAlbert Aribaud struct mvgbe_barsz { 3339b6bcdcbSAlbert Aribaud u32 bar; 3349b6bcdcbSAlbert Aribaud u32 size; 3359b6bcdcbSAlbert Aribaud }; 3369b6bcdcbSAlbert Aribaud 337d44265adSAlbert Aribaud struct mvgbe_rxcdp { 338d44265adSAlbert Aribaud struct mvgbe_rxdesc *rxcdp; 3399b6bcdcbSAlbert Aribaud u32 rxcdp_pad[3]; 3409b6bcdcbSAlbert Aribaud }; 3419b6bcdcbSAlbert Aribaud 342d44265adSAlbert Aribaud struct mvgbe_tqx { 3439b6bcdcbSAlbert Aribaud u32 qxttbc; 3449b6bcdcbSAlbert Aribaud u32 tqxtbc; 3459b6bcdcbSAlbert Aribaud u32 tqxac; 3469b6bcdcbSAlbert Aribaud u32 tqxpad; 3479b6bcdcbSAlbert Aribaud }; 3489b6bcdcbSAlbert Aribaud 349d44265adSAlbert Aribaud struct mvgbe_registers { 3509b6bcdcbSAlbert Aribaud u32 phyadr; 3519b6bcdcbSAlbert Aribaud u32 smi; 3529b6bcdcbSAlbert Aribaud u32 euda; 3539b6bcdcbSAlbert Aribaud u32 eudid; 3549b6bcdcbSAlbert Aribaud u8 pad1[0x080 - 0x00c - 4]; 3559b6bcdcbSAlbert Aribaud u32 euic; 3569b6bcdcbSAlbert Aribaud u32 euim; 3579b6bcdcbSAlbert Aribaud u8 pad2[0x094 - 0x084 - 4]; 3589b6bcdcbSAlbert Aribaud u32 euea; 3599b6bcdcbSAlbert Aribaud u32 euiae; 3609b6bcdcbSAlbert Aribaud u8 pad3[0x0b0 - 0x098 - 4]; 3619b6bcdcbSAlbert Aribaud u32 euc; 3629b6bcdcbSAlbert Aribaud u8 pad3a[0x200 - 0x0b0 - 4]; 363d44265adSAlbert Aribaud struct mvgbe_barsz barsz[6]; 3649b6bcdcbSAlbert Aribaud u8 pad4[0x280 - 0x22c - 4]; 3659b6bcdcbSAlbert Aribaud u32 ha_remap[4]; 3669b6bcdcbSAlbert Aribaud u32 bare; 3679b6bcdcbSAlbert Aribaud u32 epap; 3689b6bcdcbSAlbert Aribaud u8 pad5[0x400 - 0x294 - 4]; 3699b6bcdcbSAlbert Aribaud u32 pxc; 3709b6bcdcbSAlbert Aribaud u32 pxcx; 3719b6bcdcbSAlbert Aribaud u32 mii_ser_params; 3729b6bcdcbSAlbert Aribaud u8 pad6[0x410 - 0x408 - 4]; 3739b6bcdcbSAlbert Aribaud u32 evlane; 3749b6bcdcbSAlbert Aribaud u32 macal; 3759b6bcdcbSAlbert Aribaud u32 macah; 3769b6bcdcbSAlbert Aribaud u32 sdc; 3779b6bcdcbSAlbert Aribaud u32 dscp[7]; 3789b6bcdcbSAlbert Aribaud u32 psc0; 3799b6bcdcbSAlbert Aribaud u32 vpt2p; 3809b6bcdcbSAlbert Aribaud u32 ps0; 3819b6bcdcbSAlbert Aribaud u32 tqc; 3829b6bcdcbSAlbert Aribaud u32 psc1; 3839b6bcdcbSAlbert Aribaud u32 ps1; 3849b6bcdcbSAlbert Aribaud u32 mrvl_header; 3859b6bcdcbSAlbert Aribaud u8 pad7[0x460 - 0x454 - 4]; 3869b6bcdcbSAlbert Aribaud u32 ic; 3879b6bcdcbSAlbert Aribaud u32 ice; 3889b6bcdcbSAlbert Aribaud u32 pim; 3899b6bcdcbSAlbert Aribaud u32 peim; 3909b6bcdcbSAlbert Aribaud u8 pad8[0x474 - 0x46c - 4]; 3919b6bcdcbSAlbert Aribaud u32 pxtfut; 3929b6bcdcbSAlbert Aribaud u32 pad9; 3939b6bcdcbSAlbert Aribaud u32 pxmfs; 3949b6bcdcbSAlbert Aribaud u32 pad10; 3959b6bcdcbSAlbert Aribaud u32 pxdfc; 3969b6bcdcbSAlbert Aribaud u32 pxofc; 3979b6bcdcbSAlbert Aribaud u8 pad11[0x494 - 0x488 - 4]; 3989b6bcdcbSAlbert Aribaud u32 peuiae; 3999b6bcdcbSAlbert Aribaud u8 pad12[0x4bc - 0x494 - 4]; 4009b6bcdcbSAlbert Aribaud u32 eth_type_prio; 4019b6bcdcbSAlbert Aribaud u8 pad13[0x4dc - 0x4bc - 4]; 4029b6bcdcbSAlbert Aribaud u32 tqfpc; 4039b6bcdcbSAlbert Aribaud u32 pttbrc; 4049b6bcdcbSAlbert Aribaud u32 tqc1; 4059b6bcdcbSAlbert Aribaud u32 pmtu; 4069b6bcdcbSAlbert Aribaud u32 pmtbs; 4079b6bcdcbSAlbert Aribaud u8 pad14[0x60c - 0x4ec - 4]; 408d44265adSAlbert Aribaud struct mvgbe_rxcdp rxcdp[7]; 409d44265adSAlbert Aribaud struct mvgbe_rxdesc *rxcdp7; 4109b6bcdcbSAlbert Aribaud u32 rqc; 411d44265adSAlbert Aribaud struct mvgbe_txdesc *tcsdp; 4129b6bcdcbSAlbert Aribaud u8 pad15[0x6c0 - 0x684 - 4]; 413d44265adSAlbert Aribaud struct mvgbe_txdesc *tcqdp[8]; 4149b6bcdcbSAlbert Aribaud u8 pad16[0x700 - 0x6dc - 4]; 415d44265adSAlbert Aribaud struct mvgbe_tqx tqx[8]; 4169b6bcdcbSAlbert Aribaud u32 pttbc; 4179b6bcdcbSAlbert Aribaud u8 pad17[0x7a8 - 0x780 - 4]; 4189b6bcdcbSAlbert Aribaud u32 tqxipg0; 4199b6bcdcbSAlbert Aribaud u32 pad18[3]; 4209b6bcdcbSAlbert Aribaud u32 tqxipg1; 4219b6bcdcbSAlbert Aribaud u8 pad19[0x7c0 - 0x7b8 - 4]; 4229b6bcdcbSAlbert Aribaud u32 hitkninlopkt; 4239b6bcdcbSAlbert Aribaud u32 hitkninasyncpkt; 4249b6bcdcbSAlbert Aribaud u32 lotkninasyncpkt; 4259b6bcdcbSAlbert Aribaud u32 pad20; 4269b6bcdcbSAlbert Aribaud u32 ts; 4279b6bcdcbSAlbert Aribaud u8 pad21[0x3000 - 0x27d0 - 4]; 4289b6bcdcbSAlbert Aribaud u32 pad20_1[32]; /* mib counter registes */ 4299b6bcdcbSAlbert Aribaud u8 pad22[0x3400 - 0x3000 - sizeof(u32) * 32]; 4309b6bcdcbSAlbert Aribaud u32 dfsmt[64]; 4319b6bcdcbSAlbert Aribaud u32 dfomt[64]; 4329b6bcdcbSAlbert Aribaud u32 dfut[4]; 4339b6bcdcbSAlbert Aribaud u8 pad23[0xe20c0 - 0x7360c - 4]; 4349b6bcdcbSAlbert Aribaud u32 pmbus_top_arbiter; 4359b6bcdcbSAlbert Aribaud }; 4369b6bcdcbSAlbert Aribaud 4379b6bcdcbSAlbert Aribaud /* structures/enums needed by driver */ 438d44265adSAlbert Aribaud enum mvgbe_adrwin { 439d44265adSAlbert Aribaud MVGBE_WIN0, 440d44265adSAlbert Aribaud MVGBE_WIN1, 441d44265adSAlbert Aribaud MVGBE_WIN2, 442d44265adSAlbert Aribaud MVGBE_WIN3, 443d44265adSAlbert Aribaud MVGBE_WIN4, 444d44265adSAlbert Aribaud MVGBE_WIN5 4459b6bcdcbSAlbert Aribaud }; 4469b6bcdcbSAlbert Aribaud 447d44265adSAlbert Aribaud enum mvgbe_target { 448d44265adSAlbert Aribaud MVGBE_TARGET_DRAM, 449d44265adSAlbert Aribaud MVGBE_TARGET_DEV, 450d44265adSAlbert Aribaud MVGBE_TARGET_CBS, 451d44265adSAlbert Aribaud MVGBE_TARGET_PCI0, 452d44265adSAlbert Aribaud MVGBE_TARGET_PCI1 4539b6bcdcbSAlbert Aribaud }; 4549b6bcdcbSAlbert Aribaud 455d44265adSAlbert Aribaud struct mvgbe_winparam { 456d44265adSAlbert Aribaud enum mvgbe_adrwin win; /* Window number */ 457d44265adSAlbert Aribaud enum mvgbe_target target; /* System targets */ 4589b6bcdcbSAlbert Aribaud u16 attrib; /* BAR attrib. See above macros */ 4599b6bcdcbSAlbert Aribaud u32 base_addr; /* Window base address in u32 form */ 4609b6bcdcbSAlbert Aribaud u32 high_addr; /* Window high address in u32 form */ 4619b6bcdcbSAlbert Aribaud u32 size; /* Size in MBytes. Must be % 64Kbyte. */ 4629b6bcdcbSAlbert Aribaud int enable; /* Enable/disable access to the window. */ 4639b6bcdcbSAlbert Aribaud u16 access_ctrl; /*Access ctrl register. see above macros */ 4649b6bcdcbSAlbert Aribaud }; 4659b6bcdcbSAlbert Aribaud 466d44265adSAlbert Aribaud struct mvgbe_rxdesc { 4679b6bcdcbSAlbert Aribaud u32 cmd_sts; /* Descriptor command status */ 4689b6bcdcbSAlbert Aribaud u16 buf_size; /* Buffer size */ 4699b6bcdcbSAlbert Aribaud u16 byte_cnt; /* Descriptor buffer byte count */ 4709b6bcdcbSAlbert Aribaud u8 *buf_ptr; /* Descriptor buffer pointer */ 471d44265adSAlbert Aribaud struct mvgbe_rxdesc *nxtdesc_p; /* Next descriptor pointer */ 4729b6bcdcbSAlbert Aribaud }; 4739b6bcdcbSAlbert Aribaud 474d44265adSAlbert Aribaud struct mvgbe_txdesc { 4759b6bcdcbSAlbert Aribaud u32 cmd_sts; /* Descriptor command status */ 4769b6bcdcbSAlbert Aribaud u16 l4i_chk; /* CPU provided TCP Checksum */ 4779b6bcdcbSAlbert Aribaud u16 byte_cnt; /* Descriptor buffer byte count */ 4789b6bcdcbSAlbert Aribaud u8 *buf_ptr; /* Descriptor buffer ptr */ 479d44265adSAlbert Aribaud struct mvgbe_txdesc *nxtdesc_p; /* Next descriptor ptr */ 4809b6bcdcbSAlbert Aribaud }; 4819b6bcdcbSAlbert Aribaud 4829b6bcdcbSAlbert Aribaud /* port device data struct */ 483d44265adSAlbert Aribaud struct mvgbe_device { 484*fb731076SChris Packham #ifndef CONFIG_DM_ETH 4859b6bcdcbSAlbert Aribaud struct eth_device dev; 486*fb731076SChris Packham #endif 487d44265adSAlbert Aribaud struct mvgbe_registers *regs; 488d44265adSAlbert Aribaud struct mvgbe_txdesc *p_txdesc; 489d44265adSAlbert Aribaud struct mvgbe_rxdesc *p_rxdesc; 490d44265adSAlbert Aribaud struct mvgbe_rxdesc *p_rxdesc_curr; 4919b6bcdcbSAlbert Aribaud u8 *p_rxbuf; 4929b6bcdcbSAlbert Aribaud u8 *p_aligned_txbuf; 493*fb731076SChris Packham 494*fb731076SChris Packham #ifdef CONFIG_DM_ETH 495*fb731076SChris Packham phy_interface_t phy_interface; 496*fb731076SChris Packham unsigned int link; 497*fb731076SChris Packham unsigned int duplex; 498*fb731076SChris Packham unsigned int speed; 499*fb731076SChris Packham 500*fb731076SChris Packham int init; 501*fb731076SChris Packham int phyaddr; 502*fb731076SChris Packham struct phy_device *phydev; 503*fb731076SChris Packham struct mii_dev *bus; 504*fb731076SChris Packham #endif 5059b6bcdcbSAlbert Aribaud }; 5069b6bcdcbSAlbert Aribaud 507d44265adSAlbert Aribaud #endif /* __MVGBE_H__ */ 508