1b4af9a55SFlorian Fainelli /* 2b4af9a55SFlorian Fainelli * Copyright (c) 2014 Broadcom Corporation 3b4af9a55SFlorian Fainelli * 4b4af9a55SFlorian Fainelli * This program is free software; you can redistribute it and/or modify 5b4af9a55SFlorian Fainelli * it under the terms of the GNU General Public License version 2 as 6b4af9a55SFlorian Fainelli * published by the Free Software Foundation. 7b4af9a55SFlorian Fainelli */ 85e811b39SFlorian Fainelli 9b4af9a55SFlorian Fainelli #ifndef __BCMGENET_H__ 10b4af9a55SFlorian Fainelli #define __BCMGENET_H__ 11b4af9a55SFlorian Fainelli 12b4af9a55SFlorian Fainelli #include <linux/skbuff.h> 13b4af9a55SFlorian Fainelli #include <linux/netdevice.h> 14b4af9a55SFlorian Fainelli #include <linux/spinlock.h> 15b4af9a55SFlorian Fainelli #include <linux/clk.h> 16b4af9a55SFlorian Fainelli #include <linux/mii.h> 17b4af9a55SFlorian Fainelli #include <linux/if_vlan.h> 18b4af9a55SFlorian Fainelli #include <linux/phy.h> 19b4af9a55SFlorian Fainelli 20b4af9a55SFlorian Fainelli /* total number of Buffer Descriptors, same for Rx/Tx */ 21b4af9a55SFlorian Fainelli #define TOTAL_DESC 256 22b4af9a55SFlorian Fainelli 23b4af9a55SFlorian Fainelli /* which ring is descriptor based */ 24b4af9a55SFlorian Fainelli #define DESC_INDEX 16 25b4af9a55SFlorian Fainelli 26b4af9a55SFlorian Fainelli /* Body(1500) + EH_SIZE(14) + VLANTAG(4) + BRCMTAG(6) + FCS(4) = 1528. 27b4af9a55SFlorian Fainelli * 1536 is multiple of 256 bytes 28b4af9a55SFlorian Fainelli */ 29b4af9a55SFlorian Fainelli #define ENET_BRCM_TAG_LEN 6 30b4af9a55SFlorian Fainelli #define ENET_PAD 8 31b4af9a55SFlorian Fainelli #define ENET_MAX_MTU_SIZE (ETH_DATA_LEN + ETH_HLEN + VLAN_HLEN + \ 32b4af9a55SFlorian Fainelli ENET_BRCM_TAG_LEN + ETH_FCS_LEN + ENET_PAD) 33b4af9a55SFlorian Fainelli #define DMA_MAX_BURST_LENGTH 0x10 34b4af9a55SFlorian Fainelli 35b4af9a55SFlorian Fainelli /* misc. configuration */ 36b4af9a55SFlorian Fainelli #define CLEAR_ALL_HFB 0xFF 37b4af9a55SFlorian Fainelli #define DMA_FC_THRESH_HI (TOTAL_DESC >> 4) 38b4af9a55SFlorian Fainelli #define DMA_FC_THRESH_LO 5 39b4af9a55SFlorian Fainelli 40b4af9a55SFlorian Fainelli /* 64B receive/transmit status block */ 41b4af9a55SFlorian Fainelli struct status_64 { 42b4af9a55SFlorian Fainelli u32 length_status; /* length and peripheral status */ 43b4af9a55SFlorian Fainelli u32 ext_status; /* Extended status*/ 44b4af9a55SFlorian Fainelli u32 rx_csum; /* partial rx checksum */ 45b4af9a55SFlorian Fainelli u32 unused1[9]; /* unused */ 46b4af9a55SFlorian Fainelli u32 tx_csum_info; /* Tx checksum info. */ 47b4af9a55SFlorian Fainelli u32 unused2[3]; /* unused */ 48b4af9a55SFlorian Fainelli }; 49b4af9a55SFlorian Fainelli 50b4af9a55SFlorian Fainelli /* Rx status bits */ 51b4af9a55SFlorian Fainelli #define STATUS_RX_EXT_MASK 0x1FFFFF 52b4af9a55SFlorian Fainelli #define STATUS_RX_CSUM_MASK 0xFFFF 53b4af9a55SFlorian Fainelli #define STATUS_RX_CSUM_OK 0x10000 54b4af9a55SFlorian Fainelli #define STATUS_RX_CSUM_FR 0x20000 55b4af9a55SFlorian Fainelli #define STATUS_RX_PROTO_TCP 0 56b4af9a55SFlorian Fainelli #define STATUS_RX_PROTO_UDP 1 57b4af9a55SFlorian Fainelli #define STATUS_RX_PROTO_ICMP 2 58b4af9a55SFlorian Fainelli #define STATUS_RX_PROTO_OTHER 3 59b4af9a55SFlorian Fainelli #define STATUS_RX_PROTO_MASK 3 60b4af9a55SFlorian Fainelli #define STATUS_RX_PROTO_SHIFT 18 61b4af9a55SFlorian Fainelli #define STATUS_FILTER_INDEX_MASK 0xFFFF 62b4af9a55SFlorian Fainelli /* Tx status bits */ 63b4af9a55SFlorian Fainelli #define STATUS_TX_CSUM_START_MASK 0X7FFF 64b4af9a55SFlorian Fainelli #define STATUS_TX_CSUM_START_SHIFT 16 65b4af9a55SFlorian Fainelli #define STATUS_TX_CSUM_PROTO_UDP 0x8000 66b4af9a55SFlorian Fainelli #define STATUS_TX_CSUM_OFFSET_MASK 0x7FFF 67b4af9a55SFlorian Fainelli #define STATUS_TX_CSUM_LV 0x80000000 68b4af9a55SFlorian Fainelli 69b4af9a55SFlorian Fainelli /* DMA Descriptor */ 70b4af9a55SFlorian Fainelli #define DMA_DESC_LENGTH_STATUS 0x00 /* in bytes of data in buffer */ 71b4af9a55SFlorian Fainelli #define DMA_DESC_ADDRESS_LO 0x04 /* lower bits of PA */ 72b4af9a55SFlorian Fainelli #define DMA_DESC_ADDRESS_HI 0x08 /* upper 32 bits of PA, GENETv4+ */ 73b4af9a55SFlorian Fainelli 74b4af9a55SFlorian Fainelli /* Rx/Tx common counter group */ 75b4af9a55SFlorian Fainelli struct bcmgenet_pkt_counters { 76b4af9a55SFlorian Fainelli u32 cnt_64; /* RO Received/Transmited 64 bytes packet */ 77b4af9a55SFlorian Fainelli u32 cnt_127; /* RO Rx/Tx 127 bytes packet */ 78b4af9a55SFlorian Fainelli u32 cnt_255; /* RO Rx/Tx 65-255 bytes packet */ 79b4af9a55SFlorian Fainelli u32 cnt_511; /* RO Rx/Tx 256-511 bytes packet */ 80b4af9a55SFlorian Fainelli u32 cnt_1023; /* RO Rx/Tx 512-1023 bytes packet */ 81b4af9a55SFlorian Fainelli u32 cnt_1518; /* RO Rx/Tx 1024-1518 bytes packet */ 82b4af9a55SFlorian Fainelli u32 cnt_mgv; /* RO Rx/Tx 1519-1522 good VLAN packet */ 83b4af9a55SFlorian Fainelli u32 cnt_2047; /* RO Rx/Tx 1522-2047 bytes packet*/ 84b4af9a55SFlorian Fainelli u32 cnt_4095; /* RO Rx/Tx 2048-4095 bytes packet*/ 85b4af9a55SFlorian Fainelli u32 cnt_9216; /* RO Rx/Tx 4096-9216 bytes packet*/ 86b4af9a55SFlorian Fainelli }; 87b4af9a55SFlorian Fainelli 88b4af9a55SFlorian Fainelli /* RSV, Receive Status Vector */ 89b4af9a55SFlorian Fainelli struct bcmgenet_rx_counters { 90b4af9a55SFlorian Fainelli struct bcmgenet_pkt_counters pkt_cnt; 91b4af9a55SFlorian Fainelli u32 pkt; /* RO (0x428) Received pkt count*/ 92b4af9a55SFlorian Fainelli u32 bytes; /* RO Received byte count */ 93b4af9a55SFlorian Fainelli u32 mca; /* RO # of Received multicast pkt */ 94b4af9a55SFlorian Fainelli u32 bca; /* RO # of Receive broadcast pkt */ 95b4af9a55SFlorian Fainelli u32 fcs; /* RO # of Received FCS error */ 96b4af9a55SFlorian Fainelli u32 cf; /* RO # of Received control frame pkt*/ 97b4af9a55SFlorian Fainelli u32 pf; /* RO # of Received pause frame pkt */ 98b4af9a55SFlorian Fainelli u32 uo; /* RO # of unknown op code pkt */ 99b4af9a55SFlorian Fainelli u32 aln; /* RO # of alignment error count */ 100b4af9a55SFlorian Fainelli u32 flr; /* RO # of frame length out of range count */ 101b4af9a55SFlorian Fainelli u32 cde; /* RO # of code error pkt */ 102b4af9a55SFlorian Fainelli u32 fcr; /* RO # of carrier sense error pkt */ 103b4af9a55SFlorian Fainelli u32 ovr; /* RO # of oversize pkt*/ 104b4af9a55SFlorian Fainelli u32 jbr; /* RO # of jabber count */ 105b4af9a55SFlorian Fainelli u32 mtue; /* RO # of MTU error pkt*/ 106b4af9a55SFlorian Fainelli u32 pok; /* RO # of Received good pkt */ 107b4af9a55SFlorian Fainelli u32 uc; /* RO # of unicast pkt */ 108b4af9a55SFlorian Fainelli u32 ppp; /* RO # of PPP pkt */ 109b4af9a55SFlorian Fainelli u32 rcrc; /* RO (0x470),# of CRC match pkt */ 110b4af9a55SFlorian Fainelli }; 111b4af9a55SFlorian Fainelli 112b4af9a55SFlorian Fainelli /* TSV, Transmit Status Vector */ 113b4af9a55SFlorian Fainelli struct bcmgenet_tx_counters { 114b4af9a55SFlorian Fainelli struct bcmgenet_pkt_counters pkt_cnt; 115b4af9a55SFlorian Fainelli u32 pkts; /* RO (0x4a8) Transmited pkt */ 116b4af9a55SFlorian Fainelli u32 mca; /* RO # of xmited multicast pkt */ 117b4af9a55SFlorian Fainelli u32 bca; /* RO # of xmited broadcast pkt */ 118b4af9a55SFlorian Fainelli u32 pf; /* RO # of xmited pause frame count */ 119b4af9a55SFlorian Fainelli u32 cf; /* RO # of xmited control frame count */ 120b4af9a55SFlorian Fainelli u32 fcs; /* RO # of xmited FCS error count */ 121b4af9a55SFlorian Fainelli u32 ovr; /* RO # of xmited oversize pkt */ 122b4af9a55SFlorian Fainelli u32 drf; /* RO # of xmited deferral pkt */ 123b4af9a55SFlorian Fainelli u32 edf; /* RO # of xmited Excessive deferral pkt*/ 124b4af9a55SFlorian Fainelli u32 scl; /* RO # of xmited single collision pkt */ 125b4af9a55SFlorian Fainelli u32 mcl; /* RO # of xmited multiple collision pkt*/ 126b4af9a55SFlorian Fainelli u32 lcl; /* RO # of xmited late collision pkt */ 127b4af9a55SFlorian Fainelli u32 ecl; /* RO # of xmited excessive collision pkt*/ 128b4af9a55SFlorian Fainelli u32 frg; /* RO # of xmited fragments pkt*/ 129b4af9a55SFlorian Fainelli u32 ncl; /* RO # of xmited total collision count */ 130b4af9a55SFlorian Fainelli u32 jbr; /* RO # of xmited jabber count*/ 131b4af9a55SFlorian Fainelli u32 bytes; /* RO # of xmited byte count */ 132b4af9a55SFlorian Fainelli u32 pok; /* RO # of xmited good pkt */ 133b4af9a55SFlorian Fainelli u32 uc; /* RO (0x0x4f0)# of xmited unitcast pkt */ 134b4af9a55SFlorian Fainelli }; 135b4af9a55SFlorian Fainelli 136b4af9a55SFlorian Fainelli struct bcmgenet_mib_counters { 137b4af9a55SFlorian Fainelli struct bcmgenet_rx_counters rx; 138b4af9a55SFlorian Fainelli struct bcmgenet_tx_counters tx; 139b4af9a55SFlorian Fainelli u32 rx_runt_cnt; 140b4af9a55SFlorian Fainelli u32 rx_runt_fcs; 141b4af9a55SFlorian Fainelli u32 rx_runt_fcs_align; 142b4af9a55SFlorian Fainelli u32 rx_runt_bytes; 143b4af9a55SFlorian Fainelli u32 rbuf_ovflow_cnt; 144b4af9a55SFlorian Fainelli u32 rbuf_err_cnt; 145b4af9a55SFlorian Fainelli u32 mdf_err_cnt; 14644c8bc3cSFlorian Fainelli u32 alloc_rx_buff_failed; 14744c8bc3cSFlorian Fainelli u32 rx_dma_failed; 14844c8bc3cSFlorian Fainelli u32 tx_dma_failed; 149b4af9a55SFlorian Fainelli }; 150b4af9a55SFlorian Fainelli 151b4af9a55SFlorian Fainelli #define UMAC_HD_BKP_CTRL 0x004 152b4af9a55SFlorian Fainelli #define HD_FC_EN (1 << 0) 153b4af9a55SFlorian Fainelli #define HD_FC_BKOFF_OK (1 << 1) 154b4af9a55SFlorian Fainelli #define IPG_CONFIG_RX_SHIFT 2 155b4af9a55SFlorian Fainelli #define IPG_CONFIG_RX_MASK 0x1F 156b4af9a55SFlorian Fainelli 157b4af9a55SFlorian Fainelli #define UMAC_CMD 0x008 158b4af9a55SFlorian Fainelli #define CMD_TX_EN (1 << 0) 159b4af9a55SFlorian Fainelli #define CMD_RX_EN (1 << 1) 160b4af9a55SFlorian Fainelli #define UMAC_SPEED_10 0 161b4af9a55SFlorian Fainelli #define UMAC_SPEED_100 1 162b4af9a55SFlorian Fainelli #define UMAC_SPEED_1000 2 163b4af9a55SFlorian Fainelli #define UMAC_SPEED_2500 3 164b4af9a55SFlorian Fainelli #define CMD_SPEED_SHIFT 2 165b4af9a55SFlorian Fainelli #define CMD_SPEED_MASK 3 166b4af9a55SFlorian Fainelli #define CMD_PROMISC (1 << 4) 167b4af9a55SFlorian Fainelli #define CMD_PAD_EN (1 << 5) 168b4af9a55SFlorian Fainelli #define CMD_CRC_FWD (1 << 6) 169b4af9a55SFlorian Fainelli #define CMD_PAUSE_FWD (1 << 7) 170b4af9a55SFlorian Fainelli #define CMD_RX_PAUSE_IGNORE (1 << 8) 171b4af9a55SFlorian Fainelli #define CMD_TX_ADDR_INS (1 << 9) 172b4af9a55SFlorian Fainelli #define CMD_HD_EN (1 << 10) 173b4af9a55SFlorian Fainelli #define CMD_SW_RESET (1 << 13) 174b4af9a55SFlorian Fainelli #define CMD_LCL_LOOP_EN (1 << 15) 175b4af9a55SFlorian Fainelli #define CMD_AUTO_CONFIG (1 << 22) 176b4af9a55SFlorian Fainelli #define CMD_CNTL_FRM_EN (1 << 23) 177b4af9a55SFlorian Fainelli #define CMD_NO_LEN_CHK (1 << 24) 178b4af9a55SFlorian Fainelli #define CMD_RMT_LOOP_EN (1 << 25) 179b4af9a55SFlorian Fainelli #define CMD_PRBL_EN (1 << 27) 180b4af9a55SFlorian Fainelli #define CMD_TX_PAUSE_IGNORE (1 << 28) 181b4af9a55SFlorian Fainelli #define CMD_TX_RX_EN (1 << 29) 182b4af9a55SFlorian Fainelli #define CMD_RUNT_FILTER_DIS (1 << 30) 183b4af9a55SFlorian Fainelli 184b4af9a55SFlorian Fainelli #define UMAC_MAC0 0x00C 185b4af9a55SFlorian Fainelli #define UMAC_MAC1 0x010 186b4af9a55SFlorian Fainelli #define UMAC_MAX_FRAME_LEN 0x014 187b4af9a55SFlorian Fainelli 188d0a6db8dSFlorian Fainelli #define UMAC_EEE_CTRL 0x064 189d0a6db8dSFlorian Fainelli #define EN_LPI_RX_PAUSE (1 << 0) 190d0a6db8dSFlorian Fainelli #define EN_LPI_TX_PFC (1 << 1) 191d0a6db8dSFlorian Fainelli #define EN_LPI_TX_PAUSE (1 << 2) 192d0a6db8dSFlorian Fainelli #define EEE_EN (1 << 3) 193d0a6db8dSFlorian Fainelli #define RX_FIFO_CHECK (1 << 4) 194d0a6db8dSFlorian Fainelli #define EEE_TX_CLK_DIS (1 << 5) 195d0a6db8dSFlorian Fainelli #define DIS_EEE_10M (1 << 6) 196d0a6db8dSFlorian Fainelli #define LP_IDLE_PREDICTION_MODE (1 << 7) 197d0a6db8dSFlorian Fainelli 198d0a6db8dSFlorian Fainelli #define UMAC_EEE_LPI_TIMER 0x068 199d0a6db8dSFlorian Fainelli #define UMAC_EEE_WAKE_TIMER 0x06C 200d0a6db8dSFlorian Fainelli #define UMAC_EEE_REF_COUNT 0x070 201d0a6db8dSFlorian Fainelli #define EEE_REFERENCE_COUNT_MASK 0xffff 202d0a6db8dSFlorian Fainelli 203b4af9a55SFlorian Fainelli #define UMAC_TX_FLUSH 0x334 204b4af9a55SFlorian Fainelli 205b4af9a55SFlorian Fainelli #define UMAC_MIB_START 0x400 206b4af9a55SFlorian Fainelli 207b4af9a55SFlorian Fainelli #define UMAC_MDIO_CMD 0x614 208b4af9a55SFlorian Fainelli #define MDIO_START_BUSY (1 << 29) 209b4af9a55SFlorian Fainelli #define MDIO_READ_FAIL (1 << 28) 210b4af9a55SFlorian Fainelli #define MDIO_RD (2 << 26) 211b4af9a55SFlorian Fainelli #define MDIO_WR (1 << 26) 212b4af9a55SFlorian Fainelli #define MDIO_PMD_SHIFT 21 213b4af9a55SFlorian Fainelli #define MDIO_PMD_MASK 0x1F 214b4af9a55SFlorian Fainelli #define MDIO_REG_SHIFT 16 215b4af9a55SFlorian Fainelli #define MDIO_REG_MASK 0x1F 216b4af9a55SFlorian Fainelli 217b4af9a55SFlorian Fainelli #define UMAC_RBUF_OVFL_CNT 0x61C 218b4af9a55SFlorian Fainelli 219b4af9a55SFlorian Fainelli #define UMAC_MPD_CTRL 0x620 220b4af9a55SFlorian Fainelli #define MPD_EN (1 << 0) 221b4af9a55SFlorian Fainelli #define MPD_PW_EN (1 << 27) 222b4af9a55SFlorian Fainelli #define MPD_MSEQ_LEN_SHIFT 16 223b4af9a55SFlorian Fainelli #define MPD_MSEQ_LEN_MASK 0xFF 224b4af9a55SFlorian Fainelli 225b4af9a55SFlorian Fainelli #define UMAC_MPD_PW_MS 0x624 226b4af9a55SFlorian Fainelli #define UMAC_MPD_PW_LS 0x628 227b4af9a55SFlorian Fainelli #define UMAC_RBUF_ERR_CNT 0x634 228b4af9a55SFlorian Fainelli #define UMAC_MDF_ERR_CNT 0x638 229b4af9a55SFlorian Fainelli #define UMAC_MDF_CTRL 0x650 230b4af9a55SFlorian Fainelli #define UMAC_MDF_ADDR 0x654 231b4af9a55SFlorian Fainelli #define UMAC_MIB_CTRL 0x580 232b4af9a55SFlorian Fainelli #define MIB_RESET_RX (1 << 0) 233b4af9a55SFlorian Fainelli #define MIB_RESET_RUNT (1 << 1) 234b4af9a55SFlorian Fainelli #define MIB_RESET_TX (1 << 2) 235b4af9a55SFlorian Fainelli 236b4af9a55SFlorian Fainelli #define RBUF_CTRL 0x00 237b4af9a55SFlorian Fainelli #define RBUF_64B_EN (1 << 0) 238b4af9a55SFlorian Fainelli #define RBUF_ALIGN_2B (1 << 1) 239b4af9a55SFlorian Fainelli #define RBUF_BAD_DIS (1 << 2) 240b4af9a55SFlorian Fainelli 241b4af9a55SFlorian Fainelli #define RBUF_STATUS 0x0C 242b4af9a55SFlorian Fainelli #define RBUF_STATUS_WOL (1 << 0) 243b4af9a55SFlorian Fainelli #define RBUF_STATUS_MPD_INTR_ACTIVE (1 << 1) 244b4af9a55SFlorian Fainelli #define RBUF_STATUS_ACPI_INTR_ACTIVE (1 << 2) 245b4af9a55SFlorian Fainelli 246b4af9a55SFlorian Fainelli #define RBUF_CHK_CTRL 0x14 247b4af9a55SFlorian Fainelli #define RBUF_RXCHK_EN (1 << 0) 248b4af9a55SFlorian Fainelli #define RBUF_SKIP_FCS (1 << 4) 249b4af9a55SFlorian Fainelli 250d0a6db8dSFlorian Fainelli #define RBUF_ENERGY_CTRL 0x9c 251d0a6db8dSFlorian Fainelli #define RBUF_EEE_EN (1 << 0) 252d0a6db8dSFlorian Fainelli #define RBUF_PM_EN (1 << 1) 253d0a6db8dSFlorian Fainelli 254b4af9a55SFlorian Fainelli #define RBUF_TBUF_SIZE_CTRL 0xb4 255b4af9a55SFlorian Fainelli 256b4af9a55SFlorian Fainelli #define RBUF_HFB_CTRL_V1 0x38 257b4af9a55SFlorian Fainelli #define RBUF_HFB_FILTER_EN_SHIFT 16 258b4af9a55SFlorian Fainelli #define RBUF_HFB_FILTER_EN_MASK 0xffff0000 259b4af9a55SFlorian Fainelli #define RBUF_HFB_EN (1 << 0) 260b4af9a55SFlorian Fainelli #define RBUF_HFB_256B (1 << 1) 261b4af9a55SFlorian Fainelli #define RBUF_ACPI_EN (1 << 2) 262b4af9a55SFlorian Fainelli 263b4af9a55SFlorian Fainelli #define RBUF_HFB_LEN_V1 0x3C 264b4af9a55SFlorian Fainelli #define RBUF_FLTR_LEN_MASK 0xFF 265b4af9a55SFlorian Fainelli #define RBUF_FLTR_LEN_SHIFT 8 266b4af9a55SFlorian Fainelli 267b4af9a55SFlorian Fainelli #define TBUF_CTRL 0x00 268b4af9a55SFlorian Fainelli #define TBUF_BP_MC 0x0C 269d0a6db8dSFlorian Fainelli #define TBUF_ENERGY_CTRL 0x14 270d0a6db8dSFlorian Fainelli #define TBUF_EEE_EN (1 << 0) 271d0a6db8dSFlorian Fainelli #define TBUF_PM_EN (1 << 1) 272b4af9a55SFlorian Fainelli 273b4af9a55SFlorian Fainelli #define TBUF_CTRL_V1 0x80 274b4af9a55SFlorian Fainelli #define TBUF_BP_MC_V1 0xA0 275b4af9a55SFlorian Fainelli 276b4af9a55SFlorian Fainelli #define HFB_CTRL 0x00 277b4af9a55SFlorian Fainelli #define HFB_FLT_ENABLE_V3PLUS 0x04 278b4af9a55SFlorian Fainelli #define HFB_FLT_LEN_V2 0x04 279b4af9a55SFlorian Fainelli #define HFB_FLT_LEN_V3PLUS 0x1C 280b4af9a55SFlorian Fainelli 281b4af9a55SFlorian Fainelli /* uniMac intrl2 registers */ 282b4af9a55SFlorian Fainelli #define INTRL2_CPU_STAT 0x00 283b4af9a55SFlorian Fainelli #define INTRL2_CPU_SET 0x04 284b4af9a55SFlorian Fainelli #define INTRL2_CPU_CLEAR 0x08 285b4af9a55SFlorian Fainelli #define INTRL2_CPU_MASK_STATUS 0x0C 286b4af9a55SFlorian Fainelli #define INTRL2_CPU_MASK_SET 0x10 287b4af9a55SFlorian Fainelli #define INTRL2_CPU_MASK_CLEAR 0x14 288b4af9a55SFlorian Fainelli 289b4af9a55SFlorian Fainelli /* INTRL2 instance 0 definitions */ 290b4af9a55SFlorian Fainelli #define UMAC_IRQ_SCB (1 << 0) 291b4af9a55SFlorian Fainelli #define UMAC_IRQ_EPHY (1 << 1) 292b4af9a55SFlorian Fainelli #define UMAC_IRQ_PHY_DET_R (1 << 2) 293b4af9a55SFlorian Fainelli #define UMAC_IRQ_PHY_DET_F (1 << 3) 294b4af9a55SFlorian Fainelli #define UMAC_IRQ_LINK_UP (1 << 4) 295b4af9a55SFlorian Fainelli #define UMAC_IRQ_LINK_DOWN (1 << 5) 296e122966dSPetri Gynther #define UMAC_IRQ_LINK_EVENT (UMAC_IRQ_LINK_UP | UMAC_IRQ_LINK_DOWN) 297b4af9a55SFlorian Fainelli #define UMAC_IRQ_UMAC (1 << 6) 298b4af9a55SFlorian Fainelli #define UMAC_IRQ_UMAC_TSV (1 << 7) 299b4af9a55SFlorian Fainelli #define UMAC_IRQ_TBUF_UNDERRUN (1 << 8) 300b4af9a55SFlorian Fainelli #define UMAC_IRQ_RBUF_OVERFLOW (1 << 9) 301b4af9a55SFlorian Fainelli #define UMAC_IRQ_HFB_SM (1 << 10) 302b4af9a55SFlorian Fainelli #define UMAC_IRQ_HFB_MM (1 << 11) 303b4af9a55SFlorian Fainelli #define UMAC_IRQ_MPD_R (1 << 12) 304b4af9a55SFlorian Fainelli #define UMAC_IRQ_RXDMA_MBDONE (1 << 13) 305b4af9a55SFlorian Fainelli #define UMAC_IRQ_RXDMA_PDONE (1 << 14) 306b4af9a55SFlorian Fainelli #define UMAC_IRQ_RXDMA_BDONE (1 << 15) 307ee7d8c20SPetri Gynther #define UMAC_IRQ_RXDMA_DONE (UMAC_IRQ_RXDMA_PDONE | \ 308ee7d8c20SPetri Gynther UMAC_IRQ_RXDMA_BDONE) 309b4af9a55SFlorian Fainelli #define UMAC_IRQ_TXDMA_MBDONE (1 << 16) 310b4af9a55SFlorian Fainelli #define UMAC_IRQ_TXDMA_PDONE (1 << 17) 311b4af9a55SFlorian Fainelli #define UMAC_IRQ_TXDMA_BDONE (1 << 18) 312ee7d8c20SPetri Gynther #define UMAC_IRQ_TXDMA_DONE (UMAC_IRQ_TXDMA_PDONE | \ 313ee7d8c20SPetri Gynther UMAC_IRQ_TXDMA_BDONE) 314b4af9a55SFlorian Fainelli /* Only valid for GENETv3+ */ 315b4af9a55SFlorian Fainelli #define UMAC_IRQ_MDIO_DONE (1 << 23) 316b4af9a55SFlorian Fainelli #define UMAC_IRQ_MDIO_ERROR (1 << 24) 317b4af9a55SFlorian Fainelli 3184055eaefSPetri Gynther /* INTRL2 instance 1 definitions */ 3194055eaefSPetri Gynther #define UMAC_IRQ1_TX_INTR_MASK 0xFFFF 3204055eaefSPetri Gynther #define UMAC_IRQ1_RX_INTR_MASK 0xFFFF 3214055eaefSPetri Gynther #define UMAC_IRQ1_RX_INTR_SHIFT 16 3224055eaefSPetri Gynther 323b4af9a55SFlorian Fainelli /* Register block offsets */ 324b4af9a55SFlorian Fainelli #define GENET_SYS_OFF 0x0000 325b4af9a55SFlorian Fainelli #define GENET_GR_BRIDGE_OFF 0x0040 326b4af9a55SFlorian Fainelli #define GENET_EXT_OFF 0x0080 327b4af9a55SFlorian Fainelli #define GENET_INTRL2_0_OFF 0x0200 328b4af9a55SFlorian Fainelli #define GENET_INTRL2_1_OFF 0x0240 329b4af9a55SFlorian Fainelli #define GENET_RBUF_OFF 0x0300 330b4af9a55SFlorian Fainelli #define GENET_UMAC_OFF 0x0800 331b4af9a55SFlorian Fainelli 332b4af9a55SFlorian Fainelli /* SYS block offsets and register definitions */ 333b4af9a55SFlorian Fainelli #define SYS_REV_CTRL 0x00 334b4af9a55SFlorian Fainelli #define SYS_PORT_CTRL 0x04 335b4af9a55SFlorian Fainelli #define PORT_MODE_INT_EPHY 0 336b4af9a55SFlorian Fainelli #define PORT_MODE_INT_GPHY 1 337b4af9a55SFlorian Fainelli #define PORT_MODE_EXT_EPHY 2 338b4af9a55SFlorian Fainelli #define PORT_MODE_EXT_GPHY 3 339b4af9a55SFlorian Fainelli #define PORT_MODE_EXT_RVMII_25 (4 | BIT(4)) 340b4af9a55SFlorian Fainelli #define PORT_MODE_EXT_RVMII_50 4 341b4af9a55SFlorian Fainelli #define LED_ACT_SOURCE_MAC (1 << 9) 342b4af9a55SFlorian Fainelli 343b4af9a55SFlorian Fainelli #define SYS_RBUF_FLUSH_CTRL 0x08 344b4af9a55SFlorian Fainelli #define SYS_TBUF_FLUSH_CTRL 0x0C 345b4af9a55SFlorian Fainelli #define RBUF_FLUSH_CTRL_V1 0x04 346b4af9a55SFlorian Fainelli 347b4af9a55SFlorian Fainelli /* Ext block register offsets and definitions */ 348b4af9a55SFlorian Fainelli #define EXT_EXT_PWR_MGMT 0x00 349b4af9a55SFlorian Fainelli #define EXT_PWR_DOWN_BIAS (1 << 0) 350b4af9a55SFlorian Fainelli #define EXT_PWR_DOWN_DLL (1 << 1) 351b4af9a55SFlorian Fainelli #define EXT_PWR_DOWN_PHY (1 << 2) 352b4af9a55SFlorian Fainelli #define EXT_PWR_DN_EN_LD (1 << 3) 353b4af9a55SFlorian Fainelli #define EXT_ENERGY_DET (1 << 4) 354b4af9a55SFlorian Fainelli #define EXT_IDDQ_FROM_PHY (1 << 5) 355b4af9a55SFlorian Fainelli #define EXT_PHY_RESET (1 << 8) 356b4af9a55SFlorian Fainelli #define EXT_ENERGY_DET_MASK (1 << 12) 357b4af9a55SFlorian Fainelli 358b4af9a55SFlorian Fainelli #define EXT_RGMII_OOB_CTRL 0x0C 359b4af9a55SFlorian Fainelli #define RGMII_LINK (1 << 4) 360b4af9a55SFlorian Fainelli #define OOB_DISABLE (1 << 5) 3615a680fadSFlorian Fainelli #define RGMII_MODE_EN (1 << 6) 362b4af9a55SFlorian Fainelli #define ID_MODE_DIS (1 << 16) 363b4af9a55SFlorian Fainelli 364b4af9a55SFlorian Fainelli #define EXT_GPHY_CTRL 0x1C 365b4af9a55SFlorian Fainelli #define EXT_CFG_IDDQ_BIAS (1 << 0) 366b4af9a55SFlorian Fainelli #define EXT_CFG_PWR_DOWN (1 << 1) 3670d017e21SFlorian Fainelli #define EXT_CK25_DIS (1 << 4) 368b4af9a55SFlorian Fainelli #define EXT_GPHY_RESET (1 << 5) 369b4af9a55SFlorian Fainelli 370b4af9a55SFlorian Fainelli /* DMA rings size */ 371b4af9a55SFlorian Fainelli #define DMA_RING_SIZE (0x40) 372b4af9a55SFlorian Fainelli #define DMA_RINGS_SIZE (DMA_RING_SIZE * (DESC_INDEX + 1)) 373b4af9a55SFlorian Fainelli 374b4af9a55SFlorian Fainelli /* DMA registers common definitions */ 375b4af9a55SFlorian Fainelli #define DMA_RW_POINTER_MASK 0x1FF 376b4af9a55SFlorian Fainelli #define DMA_P_INDEX_DISCARD_CNT_MASK 0xFFFF 377b4af9a55SFlorian Fainelli #define DMA_P_INDEX_DISCARD_CNT_SHIFT 16 378b4af9a55SFlorian Fainelli #define DMA_BUFFER_DONE_CNT_MASK 0xFFFF 379b4af9a55SFlorian Fainelli #define DMA_BUFFER_DONE_CNT_SHIFT 16 380b4af9a55SFlorian Fainelli #define DMA_P_INDEX_MASK 0xFFFF 381b4af9a55SFlorian Fainelli #define DMA_C_INDEX_MASK 0xFFFF 382b4af9a55SFlorian Fainelli 383b4af9a55SFlorian Fainelli /* DMA ring size register */ 384b4af9a55SFlorian Fainelli #define DMA_RING_SIZE_MASK 0xFFFF 385b4af9a55SFlorian Fainelli #define DMA_RING_SIZE_SHIFT 16 386b4af9a55SFlorian Fainelli #define DMA_RING_BUFFER_SIZE_MASK 0xFFFF 387b4af9a55SFlorian Fainelli 388b4af9a55SFlorian Fainelli /* DMA interrupt threshold register */ 389b4af9a55SFlorian Fainelli #define DMA_INTR_THRESHOLD_MASK 0x00FF 390b4af9a55SFlorian Fainelli 391b4af9a55SFlorian Fainelli /* DMA XON/XOFF register */ 392b4af9a55SFlorian Fainelli #define DMA_XON_THREHOLD_MASK 0xFFFF 393b4af9a55SFlorian Fainelli #define DMA_XOFF_THRESHOLD_MASK 0xFFFF 394b4af9a55SFlorian Fainelli #define DMA_XOFF_THRESHOLD_SHIFT 16 395b4af9a55SFlorian Fainelli 396b4af9a55SFlorian Fainelli /* DMA flow period register */ 397b4af9a55SFlorian Fainelli #define DMA_FLOW_PERIOD_MASK 0xFFFF 398b4af9a55SFlorian Fainelli #define DMA_MAX_PKT_SIZE_MASK 0xFFFF 399b4af9a55SFlorian Fainelli #define DMA_MAX_PKT_SIZE_SHIFT 16 400b4af9a55SFlorian Fainelli 401b4af9a55SFlorian Fainelli 402b4af9a55SFlorian Fainelli /* DMA control register */ 403b4af9a55SFlorian Fainelli #define DMA_EN (1 << 0) 404b4af9a55SFlorian Fainelli #define DMA_RING_BUF_EN_SHIFT 0x01 405b4af9a55SFlorian Fainelli #define DMA_RING_BUF_EN_MASK 0xFFFF 406b4af9a55SFlorian Fainelli #define DMA_TSB_SWAP_EN (1 << 20) 407b4af9a55SFlorian Fainelli 408b4af9a55SFlorian Fainelli /* DMA status register */ 409b4af9a55SFlorian Fainelli #define DMA_DISABLED (1 << 0) 410b4af9a55SFlorian Fainelli #define DMA_DESC_RAM_INIT_BUSY (1 << 1) 411b4af9a55SFlorian Fainelli 412b4af9a55SFlorian Fainelli /* DMA SCB burst size register */ 413b4af9a55SFlorian Fainelli #define DMA_SCB_BURST_SIZE_MASK 0x1F 414b4af9a55SFlorian Fainelli 415b4af9a55SFlorian Fainelli /* DMA activity vector register */ 416b4af9a55SFlorian Fainelli #define DMA_ACTIVITY_VECTOR_MASK 0x1FFFF 417b4af9a55SFlorian Fainelli 418b4af9a55SFlorian Fainelli /* DMA backpressure mask register */ 419b4af9a55SFlorian Fainelli #define DMA_BACKPRESSURE_MASK 0x1FFFF 420b4af9a55SFlorian Fainelli #define DMA_PFC_ENABLE (1 << 31) 421b4af9a55SFlorian Fainelli 422b4af9a55SFlorian Fainelli /* DMA backpressure status register */ 423b4af9a55SFlorian Fainelli #define DMA_BACKPRESSURE_STATUS_MASK 0x1FFFF 424b4af9a55SFlorian Fainelli 425b4af9a55SFlorian Fainelli /* DMA override register */ 426b4af9a55SFlorian Fainelli #define DMA_LITTLE_ENDIAN_MODE (1 << 0) 427b4af9a55SFlorian Fainelli #define DMA_REGISTER_MODE (1 << 1) 428b4af9a55SFlorian Fainelli 429b4af9a55SFlorian Fainelli /* DMA timeout register */ 430b4af9a55SFlorian Fainelli #define DMA_TIMEOUT_MASK 0xFFFF 431b4af9a55SFlorian Fainelli #define DMA_TIMEOUT_VAL 5000 /* micro seconds */ 432b4af9a55SFlorian Fainelli 433b4af9a55SFlorian Fainelli /* TDMA rate limiting control register */ 434b4af9a55SFlorian Fainelli #define DMA_RATE_LIMIT_EN_MASK 0xFFFF 435b4af9a55SFlorian Fainelli 436b4af9a55SFlorian Fainelli /* TDMA arbitration control register */ 437b4af9a55SFlorian Fainelli #define DMA_ARBITER_MODE_MASK 0x03 438b4af9a55SFlorian Fainelli #define DMA_RING_BUF_PRIORITY_MASK 0x1F 439b4af9a55SFlorian Fainelli #define DMA_RING_BUF_PRIORITY_SHIFT 5 44037742166SPetri Gynther #define DMA_PRIO_REG_INDEX(q) ((q) / 6) 44137742166SPetri Gynther #define DMA_PRIO_REG_SHIFT(q) (((q) % 6) * DMA_RING_BUF_PRIORITY_SHIFT) 442b4af9a55SFlorian Fainelli #define DMA_RATE_ADJ_MASK 0xFF 443b4af9a55SFlorian Fainelli 444b4af9a55SFlorian Fainelli /* Tx/Rx Dma Descriptor common bits*/ 445b4af9a55SFlorian Fainelli #define DMA_BUFLENGTH_MASK 0x0fff 446b4af9a55SFlorian Fainelli #define DMA_BUFLENGTH_SHIFT 16 447b4af9a55SFlorian Fainelli #define DMA_OWN 0x8000 448b4af9a55SFlorian Fainelli #define DMA_EOP 0x4000 449b4af9a55SFlorian Fainelli #define DMA_SOP 0x2000 450b4af9a55SFlorian Fainelli #define DMA_WRAP 0x1000 451b4af9a55SFlorian Fainelli /* Tx specific Dma descriptor bits */ 452b4af9a55SFlorian Fainelli #define DMA_TX_UNDERRUN 0x0200 453b4af9a55SFlorian Fainelli #define DMA_TX_APPEND_CRC 0x0040 454b4af9a55SFlorian Fainelli #define DMA_TX_OW_CRC 0x0020 455b4af9a55SFlorian Fainelli #define DMA_TX_DO_CSUM 0x0010 456b4af9a55SFlorian Fainelli #define DMA_TX_QTAG_SHIFT 7 457b4af9a55SFlorian Fainelli 458b4af9a55SFlorian Fainelli /* Rx Specific Dma descriptor bits */ 459b4af9a55SFlorian Fainelli #define DMA_RX_CHK_V3PLUS 0x8000 460b4af9a55SFlorian Fainelli #define DMA_RX_CHK_V12 0x1000 461b4af9a55SFlorian Fainelli #define DMA_RX_BRDCAST 0x0040 462b4af9a55SFlorian Fainelli #define DMA_RX_MULT 0x0020 463b4af9a55SFlorian Fainelli #define DMA_RX_LG 0x0010 464b4af9a55SFlorian Fainelli #define DMA_RX_NO 0x0008 465b4af9a55SFlorian Fainelli #define DMA_RX_RXER 0x0004 466b4af9a55SFlorian Fainelli #define DMA_RX_CRC_ERROR 0x0002 467b4af9a55SFlorian Fainelli #define DMA_RX_OV 0x0001 468b4af9a55SFlorian Fainelli #define DMA_RX_FI_MASK 0x001F 469b4af9a55SFlorian Fainelli #define DMA_RX_FI_SHIFT 0x0007 470b4af9a55SFlorian Fainelli #define DMA_DESC_ALLOC_MASK 0x00FF 471b4af9a55SFlorian Fainelli 472b4af9a55SFlorian Fainelli #define DMA_ARBITER_RR 0x00 473b4af9a55SFlorian Fainelli #define DMA_ARBITER_WRR 0x01 474b4af9a55SFlorian Fainelli #define DMA_ARBITER_SP 0x02 475b4af9a55SFlorian Fainelli 476b4af9a55SFlorian Fainelli struct enet_cb { 477b4af9a55SFlorian Fainelli struct sk_buff *skb; 478b4af9a55SFlorian Fainelli void __iomem *bd_addr; 479b4af9a55SFlorian Fainelli DEFINE_DMA_UNMAP_ADDR(dma_addr); 480b4af9a55SFlorian Fainelli DEFINE_DMA_UNMAP_LEN(dma_len); 481b4af9a55SFlorian Fainelli }; 482b4af9a55SFlorian Fainelli 483b4af9a55SFlorian Fainelli /* power management mode */ 484b4af9a55SFlorian Fainelli enum bcmgenet_power_mode { 485b4af9a55SFlorian Fainelli GENET_POWER_CABLE_SENSE = 0, 486b4af9a55SFlorian Fainelli GENET_POWER_PASSIVE, 487c51de7f3SFlorian Fainelli GENET_POWER_WOL_MAGIC, 488b4af9a55SFlorian Fainelli }; 489b4af9a55SFlorian Fainelli 490b4af9a55SFlorian Fainelli struct bcmgenet_priv; 491b4af9a55SFlorian Fainelli 492b4af9a55SFlorian Fainelli /* We support both runtime GENET detection and compile-time 493b4af9a55SFlorian Fainelli * to optimize code-paths for a given hardware 494b4af9a55SFlorian Fainelli */ 495b4af9a55SFlorian Fainelli enum bcmgenet_version { 496b4af9a55SFlorian Fainelli GENET_V1 = 1, 497b4af9a55SFlorian Fainelli GENET_V2, 498b4af9a55SFlorian Fainelli GENET_V3, 499b4af9a55SFlorian Fainelli GENET_V4 500b4af9a55SFlorian Fainelli }; 501b4af9a55SFlorian Fainelli 502b4af9a55SFlorian Fainelli #define GENET_IS_V1(p) ((p)->version == GENET_V1) 503b4af9a55SFlorian Fainelli #define GENET_IS_V2(p) ((p)->version == GENET_V2) 504b4af9a55SFlorian Fainelli #define GENET_IS_V3(p) ((p)->version == GENET_V3) 505b4af9a55SFlorian Fainelli #define GENET_IS_V4(p) ((p)->version == GENET_V4) 506b4af9a55SFlorian Fainelli 507b4af9a55SFlorian Fainelli /* Hardware flags */ 508b4af9a55SFlorian Fainelli #define GENET_HAS_40BITS (1 << 0) 509b4af9a55SFlorian Fainelli #define GENET_HAS_EXT (1 << 1) 510b4af9a55SFlorian Fainelli #define GENET_HAS_MDIO_INTR (1 << 2) 5118d88c6ebSPetri Gynther #define GENET_HAS_MOCA_LINK_DET (1 << 3) 512b4af9a55SFlorian Fainelli 513b4af9a55SFlorian Fainelli /* BCMGENET hardware parameters, keep this structure nicely aligned 514b4af9a55SFlorian Fainelli * since it is going to be used in hot paths 515b4af9a55SFlorian Fainelli */ 516b4af9a55SFlorian Fainelli struct bcmgenet_hw_params { 517b4af9a55SFlorian Fainelli u8 tx_queues; 51851a966a7SPetri Gynther u8 tx_bds_per_q; 519b4af9a55SFlorian Fainelli u8 rx_queues; 5203feafa02SPetri Gynther u8 rx_bds_per_q; 521b4af9a55SFlorian Fainelli u8 bp_in_en_shift; 522b4af9a55SFlorian Fainelli u32 bp_in_mask; 523b4af9a55SFlorian Fainelli u8 hfb_filter_cnt; 5240034de41SPetri Gynther u8 hfb_filter_size; 525b4af9a55SFlorian Fainelli u8 qtag_mask; 526b4af9a55SFlorian Fainelli u16 tbuf_offset; 527b4af9a55SFlorian Fainelli u32 hfb_offset; 528b4af9a55SFlorian Fainelli u32 hfb_reg_offset; 529b4af9a55SFlorian Fainelli u32 rdma_offset; 530b4af9a55SFlorian Fainelli u32 tdma_offset; 531b4af9a55SFlorian Fainelli u32 words_per_bd; 532b4af9a55SFlorian Fainelli u32 flags; 533b4af9a55SFlorian Fainelli }; 534b4af9a55SFlorian Fainelli 535b4af9a55SFlorian Fainelli struct bcmgenet_tx_ring { 536b4af9a55SFlorian Fainelli spinlock_t lock; /* ring lock */ 5374092e6acSJaedon Shin struct napi_struct napi; /* NAPI per tx queue */ 538b4af9a55SFlorian Fainelli unsigned int index; /* ring index */ 539b4af9a55SFlorian Fainelli unsigned int queue; /* queue index */ 540b4af9a55SFlorian Fainelli struct enet_cb *cbs; /* tx ring buffer control block*/ 541b4af9a55SFlorian Fainelli unsigned int size; /* size of each tx ring */ 54266d06757SPetri Gynther unsigned int clean_ptr; /* Tx ring clean pointer */ 543b4af9a55SFlorian Fainelli unsigned int c_index; /* last consumer index of each ring*/ 544b4af9a55SFlorian Fainelli unsigned int free_bds; /* # of free bds for each ring */ 545b4af9a55SFlorian Fainelli unsigned int write_ptr; /* Tx ring write pointer SW copy */ 546b4af9a55SFlorian Fainelli unsigned int prod_index; /* Tx ring producer index SW copy */ 547b4af9a55SFlorian Fainelli unsigned int cb_ptr; /* Tx ring initial CB ptr */ 548b4af9a55SFlorian Fainelli unsigned int end_ptr; /* Tx ring end CB ptr */ 5499dbac28fSPetri Gynther void (*int_enable)(struct bcmgenet_tx_ring *); 5509dbac28fSPetri Gynther void (*int_disable)(struct bcmgenet_tx_ring *); 5514092e6acSJaedon Shin struct bcmgenet_priv *priv; 552b4af9a55SFlorian Fainelli }; 553b4af9a55SFlorian Fainelli 5548ac467e8SPetri Gynther struct bcmgenet_rx_ring { 5554055eaefSPetri Gynther struct napi_struct napi; /* Rx NAPI struct */ 5568ac467e8SPetri Gynther unsigned int index; /* Rx ring index */ 5578ac467e8SPetri Gynther struct enet_cb *cbs; /* Rx ring buffer control block */ 5588ac467e8SPetri Gynther unsigned int size; /* Rx ring size */ 5598ac467e8SPetri Gynther unsigned int c_index; /* Rx last consumer index */ 5608ac467e8SPetri Gynther unsigned int read_ptr; /* Rx ring read pointer */ 5618ac467e8SPetri Gynther unsigned int cb_ptr; /* Rx ring initial CB ptr */ 5628ac467e8SPetri Gynther unsigned int end_ptr; /* Rx ring end CB ptr */ 563d26ea6ccSPetri Gynther unsigned int old_discards; 5644055eaefSPetri Gynther void (*int_enable)(struct bcmgenet_rx_ring *); 5654055eaefSPetri Gynther void (*int_disable)(struct bcmgenet_rx_ring *); 5664055eaefSPetri Gynther struct bcmgenet_priv *priv; 5678ac467e8SPetri Gynther }; 5688ac467e8SPetri Gynther 569b4af9a55SFlorian Fainelli /* device context */ 570b4af9a55SFlorian Fainelli struct bcmgenet_priv { 571b4af9a55SFlorian Fainelli void __iomem *base; 572b4af9a55SFlorian Fainelli enum bcmgenet_version version; 573b4af9a55SFlorian Fainelli struct net_device *dev; 574b4af9a55SFlorian Fainelli 575b4af9a55SFlorian Fainelli /* transmit variables */ 576b4af9a55SFlorian Fainelli void __iomem *tx_bds; 577b4af9a55SFlorian Fainelli struct enet_cb *tx_cbs; 578b4af9a55SFlorian Fainelli unsigned int num_tx_bds; 579b4af9a55SFlorian Fainelli 580b4af9a55SFlorian Fainelli struct bcmgenet_tx_ring tx_rings[DESC_INDEX + 1]; 581b4af9a55SFlorian Fainelli 582b4af9a55SFlorian Fainelli /* receive variables */ 583b4af9a55SFlorian Fainelli void __iomem *rx_bds; 584b4af9a55SFlorian Fainelli struct enet_cb *rx_cbs; 585b4af9a55SFlorian Fainelli unsigned int num_rx_bds; 586b4af9a55SFlorian Fainelli unsigned int rx_buf_len; 5878ac467e8SPetri Gynther 5888ac467e8SPetri Gynther struct bcmgenet_rx_ring rx_rings[DESC_INDEX + 1]; 589b4af9a55SFlorian Fainelli 590b4af9a55SFlorian Fainelli /* other misc variables */ 591b4af9a55SFlorian Fainelli struct bcmgenet_hw_params *hw_params; 592b4af9a55SFlorian Fainelli 593b4af9a55SFlorian Fainelli /* MDIO bus variables */ 594b4af9a55SFlorian Fainelli wait_queue_head_t wq; 595b4af9a55SFlorian Fainelli struct phy_device *phydev; 596c624f891SFlorian Fainelli bool internal_phy; 597b4af9a55SFlorian Fainelli struct device_node *phy_dn; 5987b635da8SFlorian Fainelli struct device_node *mdio_dn; 599b4af9a55SFlorian Fainelli struct mii_bus *mii_bus; 600487320c5SFlorian Fainelli u16 gphy_rev; 6016ef398eaSFlorian Fainelli struct clk *clk_eee; 6026ef398eaSFlorian Fainelli bool clk_eee_enabled; 603b4af9a55SFlorian Fainelli 604b4af9a55SFlorian Fainelli /* PHY device variables */ 605b4af9a55SFlorian Fainelli int old_link; 6065ad6e6c5SPetri Gynther int old_speed; 6075ad6e6c5SPetri Gynther int old_duplex; 608b4af9a55SFlorian Fainelli int old_pause; 609b4af9a55SFlorian Fainelli phy_interface_t phy_interface; 610b4af9a55SFlorian Fainelli int phy_addr; 611b4af9a55SFlorian Fainelli int ext_phy; 612b4af9a55SFlorian Fainelli 613b4af9a55SFlorian Fainelli /* Interrupt variables */ 614b4af9a55SFlorian Fainelli struct work_struct bcmgenet_irq_work; 615b4af9a55SFlorian Fainelli int irq0; 616b4af9a55SFlorian Fainelli int irq1; 617b4af9a55SFlorian Fainelli unsigned int irq0_stat; 618b4af9a55SFlorian Fainelli unsigned int irq1_stat; 6198562056fSFlorian Fainelli int wol_irq; 6208562056fSFlorian Fainelli bool wol_irq_disabled; 621b4af9a55SFlorian Fainelli 622b4af9a55SFlorian Fainelli /* HW descriptors/checksum variables */ 623b4af9a55SFlorian Fainelli bool desc_64b_en; 624b4af9a55SFlorian Fainelli bool desc_rxchk_en; 625b4af9a55SFlorian Fainelli bool crc_fwd_en; 626b4af9a55SFlorian Fainelli 627b4af9a55SFlorian Fainelli unsigned int dma_rx_chk_bit; 628b4af9a55SFlorian Fainelli 629b4af9a55SFlorian Fainelli u32 msg_enable; 630b4af9a55SFlorian Fainelli 631b4af9a55SFlorian Fainelli struct clk *clk; 632b4af9a55SFlorian Fainelli struct platform_device *pdev; 633b4af9a55SFlorian Fainelli 634b4af9a55SFlorian Fainelli /* WOL */ 635b4af9a55SFlorian Fainelli struct clk *clk_wol; 636b4af9a55SFlorian Fainelli u32 wolopts; 637b4af9a55SFlorian Fainelli 638b4af9a55SFlorian Fainelli struct bcmgenet_mib_counters mib; 6396ef398eaSFlorian Fainelli 6406ef398eaSFlorian Fainelli struct ethtool_eee eee; 641b4af9a55SFlorian Fainelli }; 642b4af9a55SFlorian Fainelli 643b4af9a55SFlorian Fainelli #define GENET_IO_MACRO(name, offset) \ 644b4af9a55SFlorian Fainelli static inline u32 bcmgenet_##name##_readl(struct bcmgenet_priv *priv, \ 645b4af9a55SFlorian Fainelli u32 off) \ 646b4af9a55SFlorian Fainelli { \ 647b4af9a55SFlorian Fainelli return __raw_readl(priv->base + offset + off); \ 648b4af9a55SFlorian Fainelli } \ 649b4af9a55SFlorian Fainelli static inline void bcmgenet_##name##_writel(struct bcmgenet_priv *priv, \ 650b4af9a55SFlorian Fainelli u32 val, u32 off) \ 651b4af9a55SFlorian Fainelli { \ 652b4af9a55SFlorian Fainelli __raw_writel(val, priv->base + offset + off); \ 653b4af9a55SFlorian Fainelli } 654b4af9a55SFlorian Fainelli 655b4af9a55SFlorian Fainelli GENET_IO_MACRO(ext, GENET_EXT_OFF); 656b4af9a55SFlorian Fainelli GENET_IO_MACRO(umac, GENET_UMAC_OFF); 657b4af9a55SFlorian Fainelli GENET_IO_MACRO(sys, GENET_SYS_OFF); 658b4af9a55SFlorian Fainelli 659b4af9a55SFlorian Fainelli /* interrupt l2 registers accessors */ 660b4af9a55SFlorian Fainelli GENET_IO_MACRO(intrl2_0, GENET_INTRL2_0_OFF); 661b4af9a55SFlorian Fainelli GENET_IO_MACRO(intrl2_1, GENET_INTRL2_1_OFF); 662b4af9a55SFlorian Fainelli 663b4af9a55SFlorian Fainelli /* HFB register accessors */ 664b4af9a55SFlorian Fainelli GENET_IO_MACRO(hfb, priv->hw_params->hfb_offset); 665b4af9a55SFlorian Fainelli 666b4af9a55SFlorian Fainelli /* GENET v2+ HFB control and filter len helpers */ 667b4af9a55SFlorian Fainelli GENET_IO_MACRO(hfb_reg, priv->hw_params->hfb_reg_offset); 668b4af9a55SFlorian Fainelli 669b4af9a55SFlorian Fainelli /* RBUF register accessors */ 670b4af9a55SFlorian Fainelli GENET_IO_MACRO(rbuf, GENET_RBUF_OFF); 671b4af9a55SFlorian Fainelli 672b4af9a55SFlorian Fainelli /* MDIO routines */ 673b4af9a55SFlorian Fainelli int bcmgenet_mii_init(struct net_device *dev); 674dbd479dbSFlorian Fainelli int bcmgenet_mii_config(struct net_device *dev, bool init); 6756cc8e6d4SFlorian Fainelli int bcmgenet_mii_probe(struct net_device *dev); 676b4af9a55SFlorian Fainelli void bcmgenet_mii_exit(struct net_device *dev); 677a642c4f7SFlorian Fainelli void bcmgenet_phy_power_set(struct net_device *dev, bool enable); 678c96e731cSFlorian Fainelli void bcmgenet_mii_setup(struct net_device *dev); 679b4af9a55SFlorian Fainelli 680c51de7f3SFlorian Fainelli /* Wake-on-LAN routines */ 681c51de7f3SFlorian Fainelli void bcmgenet_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol); 682c51de7f3SFlorian Fainelli int bcmgenet_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol); 683c51de7f3SFlorian Fainelli int bcmgenet_wol_power_down_cfg(struct bcmgenet_priv *priv, 684c51de7f3SFlorian Fainelli enum bcmgenet_power_mode mode); 685c51de7f3SFlorian Fainelli void bcmgenet_wol_power_up_cfg(struct bcmgenet_priv *priv, 686c51de7f3SFlorian Fainelli enum bcmgenet_power_mode mode); 687c51de7f3SFlorian Fainelli 688b4af9a55SFlorian Fainelli #endif /* __BCMGENET_H__ */ 689