18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0+ */
28c2ecf20Sopenharmony_ci/* $Id: cassini.h,v 1.16 2004/08/17 21:15:16 zaumen Exp $
38c2ecf20Sopenharmony_ci * cassini.h: Definitions for Sun Microsystems Cassini(+) ethernet driver.
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (C) 2004 Sun Microsystems Inc.
68c2ecf20Sopenharmony_ci * Copyright (c) 2003 Adrian Sun (asun@darksunrising.com)
78c2ecf20Sopenharmony_ci *
88c2ecf20Sopenharmony_ci * vendor id: 0x108E (Sun Microsystems, Inc.)
98c2ecf20Sopenharmony_ci * device id: 0xabba (Cassini)
108c2ecf20Sopenharmony_ci * revision ids: 0x01 = Cassini
118c2ecf20Sopenharmony_ci *               0x02 = Cassini rev 2
128c2ecf20Sopenharmony_ci *               0x10 = Cassini+
138c2ecf20Sopenharmony_ci *               0x11 = Cassini+ 0.2u
148c2ecf20Sopenharmony_ci *
158c2ecf20Sopenharmony_ci * vendor id: 0x100b (National Semiconductor)
168c2ecf20Sopenharmony_ci * device id: 0x0035 (DP83065/Saturn)
178c2ecf20Sopenharmony_ci * revision ids: 0x30 = Saturn B2
188c2ecf20Sopenharmony_ci *
198c2ecf20Sopenharmony_ci * rings are all offset from 0.
208c2ecf20Sopenharmony_ci *
218c2ecf20Sopenharmony_ci * there are two clock domains:
228c2ecf20Sopenharmony_ci * PCI:  33/66MHz clock
238c2ecf20Sopenharmony_ci * chip: 125MHz clock
248c2ecf20Sopenharmony_ci */
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci#ifndef _CASSINI_H
278c2ecf20Sopenharmony_ci#define _CASSINI_H
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci/* cassini register map: 2M memory mapped in 32-bit memory space accessible as
308c2ecf20Sopenharmony_ci * 32-bit words. there is no i/o port access. REG_ addresses are
318c2ecf20Sopenharmony_ci * shared between cassini and cassini+. REG_PLUS_ addresses only
328c2ecf20Sopenharmony_ci * appear in cassini+. REG_MINUS_ addresses only appear in cassini.
338c2ecf20Sopenharmony_ci */
348c2ecf20Sopenharmony_ci#define CAS_ID_REV2          0x02
358c2ecf20Sopenharmony_ci#define CAS_ID_REVPLUS       0x10
368c2ecf20Sopenharmony_ci#define CAS_ID_REVPLUS02u    0x11
378c2ecf20Sopenharmony_ci#define CAS_ID_REVSATURNB2   0x30
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci/** global resources **/
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci/* this register sets the weights for the weighted round robin arbiter. e.g.,
428c2ecf20Sopenharmony_ci * if rx weight == 1 and tx weight == 0, rx == 2x tx transfer credit
438c2ecf20Sopenharmony_ci * for its next turn to access the pci bus.
448c2ecf20Sopenharmony_ci * map: 0x0 = x1, 0x1 = x2, 0x2 = x4, 0x3 = x8
458c2ecf20Sopenharmony_ci * DEFAULT: 0x0, SIZE: 5 bits
468c2ecf20Sopenharmony_ci */
478c2ecf20Sopenharmony_ci#define  REG_CAWR	               0x0004  /* core arbitration weight */
488c2ecf20Sopenharmony_ci#define    CAWR_RX_DMA_WEIGHT_SHIFT    0
498c2ecf20Sopenharmony_ci#define    CAWR_RX_DMA_WEIGHT_MASK     0x03    /* [0:1] */
508c2ecf20Sopenharmony_ci#define    CAWR_TX_DMA_WEIGHT_SHIFT    2
518c2ecf20Sopenharmony_ci#define    CAWR_TX_DMA_WEIGHT_MASK     0x0C    /* [3:2] */
528c2ecf20Sopenharmony_ci#define    CAWR_RR_DIS                 0x10    /* [4] */
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci/* if enabled, BIM can send bursts across PCI bus > cacheline size. burst
558c2ecf20Sopenharmony_ci * sizes determined by length of packet or descriptor transfer and the
568c2ecf20Sopenharmony_ci * max length allowed by the target.
578c2ecf20Sopenharmony_ci * DEFAULT: 0x0, SIZE: 1 bit
588c2ecf20Sopenharmony_ci */
598c2ecf20Sopenharmony_ci#define  REG_INF_BURST                 0x0008  /* infinite burst enable reg */
608c2ecf20Sopenharmony_ci#define    INF_BURST_EN                0x1     /* enable */
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ci/* top level interrupts [0-9] are auto-cleared to 0 when the status
638c2ecf20Sopenharmony_ci * register is read. second level interrupts [13 - 18] are cleared at
648c2ecf20Sopenharmony_ci * the source. tx completion register 3 is replicated in [19 - 31]
658c2ecf20Sopenharmony_ci * DEFAULT: 0x00000000, SIZE: 29 bits
668c2ecf20Sopenharmony_ci */
678c2ecf20Sopenharmony_ci#define  REG_INTR_STATUS               0x000C  /* interrupt status register */
688c2ecf20Sopenharmony_ci#define    INTR_TX_INTME               0x00000001  /* frame w/ INT ME desc bit set
698c2ecf20Sopenharmony_ci						      xferred from host queue to
708c2ecf20Sopenharmony_ci						      TX FIFO */
718c2ecf20Sopenharmony_ci#define    INTR_TX_ALL                 0x00000002  /* all xmit frames xferred into
728c2ecf20Sopenharmony_ci						      TX FIFO. i.e.,
738c2ecf20Sopenharmony_ci						      TX Kick == TX complete. if
748c2ecf20Sopenharmony_ci						      PACED_MODE set, then TX FIFO
758c2ecf20Sopenharmony_ci						      also empty */
768c2ecf20Sopenharmony_ci#define    INTR_TX_DONE                0x00000004  /* any frame xferred into tx
778c2ecf20Sopenharmony_ci						      FIFO */
788c2ecf20Sopenharmony_ci#define    INTR_TX_TAG_ERROR           0x00000008  /* TX FIFO tag framing
798c2ecf20Sopenharmony_ci						      corrupted. FATAL ERROR */
808c2ecf20Sopenharmony_ci#define    INTR_RX_DONE                0x00000010  /* at least 1 frame xferred
818c2ecf20Sopenharmony_ci						      from RX FIFO to host mem.
828c2ecf20Sopenharmony_ci						      RX completion reg updated.
838c2ecf20Sopenharmony_ci						      may be delayed by recv
848c2ecf20Sopenharmony_ci						      intr blanking. */
858c2ecf20Sopenharmony_ci#define    INTR_RX_BUF_UNAVAIL         0x00000020  /* no more receive buffers.
868c2ecf20Sopenharmony_ci						      RX Kick == RX complete */
878c2ecf20Sopenharmony_ci#define    INTR_RX_TAG_ERROR           0x00000040  /* RX FIFO tag framing
888c2ecf20Sopenharmony_ci						      corrupted. FATAL ERROR */
898c2ecf20Sopenharmony_ci#define    INTR_RX_COMP_FULL           0x00000080  /* no more room in completion
908c2ecf20Sopenharmony_ci						      ring to post descriptors.
918c2ecf20Sopenharmony_ci						      RX complete head incr to
928c2ecf20Sopenharmony_ci						      almost reach RX complete
938c2ecf20Sopenharmony_ci						      tail */
948c2ecf20Sopenharmony_ci#define    INTR_RX_BUF_AE              0x00000100  /* less than the
958c2ecf20Sopenharmony_ci						      programmable threshold #
968c2ecf20Sopenharmony_ci						      of free descr avail for
978c2ecf20Sopenharmony_ci						      hw use */
988c2ecf20Sopenharmony_ci#define    INTR_RX_COMP_AF             0x00000200  /* less than the
998c2ecf20Sopenharmony_ci						      programmable threshold #
1008c2ecf20Sopenharmony_ci						      of descr spaces for hw
1018c2ecf20Sopenharmony_ci						      use in completion descr
1028c2ecf20Sopenharmony_ci						      ring */
1038c2ecf20Sopenharmony_ci#define    INTR_RX_LEN_MISMATCH        0x00000400  /* len field from MAC !=
1048c2ecf20Sopenharmony_ci						      len of non-reassembly pkt
1058c2ecf20Sopenharmony_ci						      from fifo during DMA or
1068c2ecf20Sopenharmony_ci						      header parser provides TCP
1078c2ecf20Sopenharmony_ci						      header and payload size >
1088c2ecf20Sopenharmony_ci						      MAC packet size.
1098c2ecf20Sopenharmony_ci						      FATAL ERROR */
1108c2ecf20Sopenharmony_ci#define    INTR_SUMMARY                0x00001000  /* summary interrupt bit. this
1118c2ecf20Sopenharmony_ci						      bit will be set if an interrupt
1128c2ecf20Sopenharmony_ci						      generated on the pci bus. useful
1138c2ecf20Sopenharmony_ci						      when driver is polling for
1148c2ecf20Sopenharmony_ci						      interrupts */
1158c2ecf20Sopenharmony_ci#define    INTR_PCS_STATUS             0x00002000  /* PCS interrupt status register */
1168c2ecf20Sopenharmony_ci#define    INTR_TX_MAC_STATUS          0x00004000  /* TX MAC status register has at
1178c2ecf20Sopenharmony_ci						      least 1 unmasked interrupt set */
1188c2ecf20Sopenharmony_ci#define    INTR_RX_MAC_STATUS          0x00008000  /* RX MAC status register has at
1198c2ecf20Sopenharmony_ci						      least 1 unmasked interrupt set */
1208c2ecf20Sopenharmony_ci#define    INTR_MAC_CTRL_STATUS        0x00010000  /* MAC control status register has
1218c2ecf20Sopenharmony_ci						      at least 1 unmasked interrupt
1228c2ecf20Sopenharmony_ci						      set */
1238c2ecf20Sopenharmony_ci#define    INTR_MIF_STATUS             0x00020000  /* MIF status register has at least
1248c2ecf20Sopenharmony_ci						      1 unmasked interrupt set */
1258c2ecf20Sopenharmony_ci#define    INTR_PCI_ERROR_STATUS       0x00040000  /* PCI error status register in the
1268c2ecf20Sopenharmony_ci						      BIF has at least 1 unmasked
1278c2ecf20Sopenharmony_ci						      interrupt set */
1288c2ecf20Sopenharmony_ci#define    INTR_TX_COMP_3_MASK         0xFFF80000  /* mask for TX completion
1298c2ecf20Sopenharmony_ci						      3 reg data */
1308c2ecf20Sopenharmony_ci#define    INTR_TX_COMP_3_SHIFT        19
1318c2ecf20Sopenharmony_ci#define    INTR_ERROR_MASK (INTR_MIF_STATUS | INTR_PCI_ERROR_STATUS | \
1328c2ecf20Sopenharmony_ci                            INTR_PCS_STATUS | INTR_RX_LEN_MISMATCH | \
1338c2ecf20Sopenharmony_ci                            INTR_TX_MAC_STATUS | INTR_RX_MAC_STATUS | \
1348c2ecf20Sopenharmony_ci                            INTR_TX_TAG_ERROR | INTR_RX_TAG_ERROR | \
1358c2ecf20Sopenharmony_ci                            INTR_MAC_CTRL_STATUS)
1368c2ecf20Sopenharmony_ci
1378c2ecf20Sopenharmony_ci/* determines which status events will cause an interrupt. layout same
1388c2ecf20Sopenharmony_ci * as REG_INTR_STATUS.
1398c2ecf20Sopenharmony_ci * DEFAULT: 0xFFFFFFFF, SIZE: 16 bits
1408c2ecf20Sopenharmony_ci */
1418c2ecf20Sopenharmony_ci#define  REG_INTR_MASK                 0x0010  /* Interrupt mask */
1428c2ecf20Sopenharmony_ci
1438c2ecf20Sopenharmony_ci/* top level interrupt bits that are cleared during read of REG_INTR_STATUS_ALIAS.
1448c2ecf20Sopenharmony_ci * useful when driver is polling for interrupts. layout same as REG_INTR_MASK.
1458c2ecf20Sopenharmony_ci * DEFAULT: 0x00000000, SIZE: 12 bits
1468c2ecf20Sopenharmony_ci */
1478c2ecf20Sopenharmony_ci#define  REG_ALIAS_CLEAR               0x0014  /* alias clear mask
1488c2ecf20Sopenharmony_ci						  (used w/ status alias) */
1498c2ecf20Sopenharmony_ci/* same as REG_INTR_STATUS except that only bits cleared are those selected by
1508c2ecf20Sopenharmony_ci * REG_ALIAS_CLEAR
1518c2ecf20Sopenharmony_ci * DEFAULT: 0x00000000, SIZE: 29 bits
1528c2ecf20Sopenharmony_ci */
1538c2ecf20Sopenharmony_ci#define  REG_INTR_STATUS_ALIAS         0x001C  /* interrupt status alias
1548c2ecf20Sopenharmony_ci						  (selective clear) */
1558c2ecf20Sopenharmony_ci
1568c2ecf20Sopenharmony_ci/* DEFAULT: 0x0, SIZE: 3 bits */
1578c2ecf20Sopenharmony_ci#define  REG_PCI_ERR_STATUS            0x1000  /* PCI error status */
1588c2ecf20Sopenharmony_ci#define    PCI_ERR_BADACK              0x01    /* reserved in Cassini+.
1598c2ecf20Sopenharmony_ci						  set if no ACK64# during ABS64 cycle
1608c2ecf20Sopenharmony_ci						  in Cassini. */
1618c2ecf20Sopenharmony_ci#define    PCI_ERR_DTRTO               0x02    /* delayed xaction timeout. set if
1628c2ecf20Sopenharmony_ci						  no read retry after 2^15 clocks */
1638c2ecf20Sopenharmony_ci#define    PCI_ERR_OTHER               0x04    /* other PCI errors */
1648c2ecf20Sopenharmony_ci#define    PCI_ERR_BIM_DMA_WRITE       0x08    /* BIM received 0 count DMA write req.
1658c2ecf20Sopenharmony_ci						  unused in Cassini. */
1668c2ecf20Sopenharmony_ci#define    PCI_ERR_BIM_DMA_READ        0x10    /* BIM received 0 count DMA read req.
1678c2ecf20Sopenharmony_ci						  unused in Cassini. */
1688c2ecf20Sopenharmony_ci#define    PCI_ERR_BIM_DMA_TIMEOUT     0x20    /* BIM received 255 retries during
1698c2ecf20Sopenharmony_ci						  DMA. unused in cassini. */
1708c2ecf20Sopenharmony_ci
1718c2ecf20Sopenharmony_ci/* mask for PCI status events that will set PCI_ERR_STATUS. if cleared, event
1728c2ecf20Sopenharmony_ci * causes an interrupt to be generated.
1738c2ecf20Sopenharmony_ci * DEFAULT: 0x7, SIZE: 3 bits
1748c2ecf20Sopenharmony_ci */
1758c2ecf20Sopenharmony_ci#define  REG_PCI_ERR_STATUS_MASK       0x1004  /* PCI Error status mask */
1768c2ecf20Sopenharmony_ci
1778c2ecf20Sopenharmony_ci/* used to configure PCI related parameters that are not in PCI config space.
1788c2ecf20Sopenharmony_ci * DEFAULT: 0bxx000, SIZE: 5 bits
1798c2ecf20Sopenharmony_ci */
1808c2ecf20Sopenharmony_ci#define  REG_BIM_CFG                0x1008  /* BIM Configuration */
1818c2ecf20Sopenharmony_ci#define    BIM_CFG_RESERVED0        0x001   /* reserved */
1828c2ecf20Sopenharmony_ci#define    BIM_CFG_RESERVED1        0x002   /* reserved */
1838c2ecf20Sopenharmony_ci#define    BIM_CFG_64BIT_DISABLE    0x004   /* disable 64-bit mode */
1848c2ecf20Sopenharmony_ci#define    BIM_CFG_66MHZ            0x008   /* (ro) 1 = 66MHz, 0 = < 66MHz */
1858c2ecf20Sopenharmony_ci#define    BIM_CFG_32BIT            0x010   /* (ro) 1 = 32-bit slot, 0 = 64-bit */
1868c2ecf20Sopenharmony_ci#define    BIM_CFG_DPAR_INTR_ENABLE 0x020   /* detected parity err enable */
1878c2ecf20Sopenharmony_ci#define    BIM_CFG_RMA_INTR_ENABLE  0x040   /* master abort intr enable */
1888c2ecf20Sopenharmony_ci#define    BIM_CFG_RTA_INTR_ENABLE  0x080   /* target abort intr enable */
1898c2ecf20Sopenharmony_ci#define    BIM_CFG_RESERVED2        0x100   /* reserved */
1908c2ecf20Sopenharmony_ci#define    BIM_CFG_BIM_DISABLE      0x200   /* stop BIM DMA. use before global
1918c2ecf20Sopenharmony_ci					       reset. reserved in Cassini. */
1928c2ecf20Sopenharmony_ci#define    BIM_CFG_BIM_STATUS       0x400   /* (ro) 1 = BIM DMA suspended.
1938c2ecf20Sopenharmony_ci						  reserved in Cassini. */
1948c2ecf20Sopenharmony_ci#define    BIM_CFG_PERROR_BLOCK     0x800  /* block PERR# to pci bus. def: 0.
1958c2ecf20Sopenharmony_ci						 reserved in Cassini. */
1968c2ecf20Sopenharmony_ci
1978c2ecf20Sopenharmony_ci/* DEFAULT: 0x00000000, SIZE: 32 bits */
1988c2ecf20Sopenharmony_ci#define  REG_BIM_DIAG                  0x100C  /* BIM Diagnostic */
1998c2ecf20Sopenharmony_ci#define    BIM_DIAG_MSTR_SM_MASK       0x3FFFFF00 /* PCI master controller state
2008c2ecf20Sopenharmony_ci						     machine bits [21:0] */
2018c2ecf20Sopenharmony_ci#define    BIM_DIAG_BRST_SM_MASK       0x7F    /* PCI burst controller state
2028c2ecf20Sopenharmony_ci						  machine bits [6:0] */
2038c2ecf20Sopenharmony_ci
2048c2ecf20Sopenharmony_ci/* writing to SW_RESET_TX and SW_RESET_RX will issue a global
2058c2ecf20Sopenharmony_ci * reset. poll until TX and RX read back as 0's for completion.
2068c2ecf20Sopenharmony_ci */
2078c2ecf20Sopenharmony_ci#define  REG_SW_RESET                  0x1010  /* Software reset */
2088c2ecf20Sopenharmony_ci#define    SW_RESET_TX                 0x00000001  /* reset TX DMA engine. poll until
2098c2ecf20Sopenharmony_ci						      cleared to 0.  */
2108c2ecf20Sopenharmony_ci#define    SW_RESET_RX                 0x00000002  /* reset RX DMA engine. poll until
2118c2ecf20Sopenharmony_ci						      cleared to 0. */
2128c2ecf20Sopenharmony_ci#define    SW_RESET_RSTOUT             0x00000004  /* force RSTOUT# pin active (low).
2138c2ecf20Sopenharmony_ci						      resets PHY and anything else
2148c2ecf20Sopenharmony_ci						      connected to RSTOUT#. RSTOUT#
2158c2ecf20Sopenharmony_ci						      is also activated by local PCI
2168c2ecf20Sopenharmony_ci						      reset when hot-swap is being
2178c2ecf20Sopenharmony_ci						      done. */
2188c2ecf20Sopenharmony_ci#define    SW_RESET_BLOCK_PCS_SLINK    0x00000008  /* if a global reset is done with
2198c2ecf20Sopenharmony_ci						      this bit set, PCS and SLINK
2208c2ecf20Sopenharmony_ci						      modules won't be reset.
2218c2ecf20Sopenharmony_ci						      i.e., link won't drop. */
2228c2ecf20Sopenharmony_ci#define    SW_RESET_BREQ_SM_MASK       0x00007F00  /* breq state machine [6:0] */
2238c2ecf20Sopenharmony_ci#define    SW_RESET_PCIARB_SM_MASK     0x00070000  /* pci arbitration state bits:
2248c2ecf20Sopenharmony_ci						      0b000: ARB_IDLE1
2258c2ecf20Sopenharmony_ci						      0b001: ARB_IDLE2
2268c2ecf20Sopenharmony_ci						      0b010: ARB_WB_ACK
2278c2ecf20Sopenharmony_ci						      0b011: ARB_WB_WAT
2288c2ecf20Sopenharmony_ci						      0b100: ARB_RB_ACK
2298c2ecf20Sopenharmony_ci						      0b101: ARB_RB_WAT
2308c2ecf20Sopenharmony_ci						      0b110: ARB_RB_END
2318c2ecf20Sopenharmony_ci						      0b111: ARB_WB_END */
2328c2ecf20Sopenharmony_ci#define    SW_RESET_RDPCI_SM_MASK      0x00300000  /* read pci state bits:
2338c2ecf20Sopenharmony_ci						      0b00: RD_PCI_WAT
2348c2ecf20Sopenharmony_ci						      0b01: RD_PCI_RDY
2358c2ecf20Sopenharmony_ci						      0b11: RD_PCI_ACK */
2368c2ecf20Sopenharmony_ci#define    SW_RESET_RDARB_SM_MASK      0x00C00000  /* read arbitration state bits:
2378c2ecf20Sopenharmony_ci						      0b00: AD_IDL_RX
2388c2ecf20Sopenharmony_ci						      0b01: AD_ACK_RX
2398c2ecf20Sopenharmony_ci						      0b10: AD_ACK_TX
2408c2ecf20Sopenharmony_ci						      0b11: AD_IDL_TX */
2418c2ecf20Sopenharmony_ci#define    SW_RESET_WRPCI_SM_MASK      0x06000000  /* write pci state bits
2428c2ecf20Sopenharmony_ci						      0b00: WR_PCI_WAT
2438c2ecf20Sopenharmony_ci						      0b01: WR_PCI_RDY
2448c2ecf20Sopenharmony_ci						      0b11: WR_PCI_ACK */
2458c2ecf20Sopenharmony_ci#define    SW_RESET_WRARB_SM_MASK      0x38000000  /* write arbitration state bits:
2468c2ecf20Sopenharmony_ci						      0b000: ARB_IDLE1
2478c2ecf20Sopenharmony_ci						      0b001: ARB_IDLE2
2488c2ecf20Sopenharmony_ci						      0b010: ARB_TX_ACK
2498c2ecf20Sopenharmony_ci						      0b011: ARB_TX_WAT
2508c2ecf20Sopenharmony_ci						      0b100: ARB_RX_ACK
2518c2ecf20Sopenharmony_ci						      0b110: ARB_RX_WAT */
2528c2ecf20Sopenharmony_ci
2538c2ecf20Sopenharmony_ci/* Cassini only. 64-bit register used to check PCI datapath. when read,
2548c2ecf20Sopenharmony_ci * value written has both lower and upper 32-bit halves rotated to the right
2558c2ecf20Sopenharmony_ci * one bit position. e.g., FFFFFFFF FFFFFFFF -> 7FFFFFFF 7FFFFFFF
2568c2ecf20Sopenharmony_ci */
2578c2ecf20Sopenharmony_ci#define  REG_MINUS_BIM_DATAPATH_TEST   0x1018  /* Cassini: BIM datapath test
2588c2ecf20Sopenharmony_ci						  Cassini+: reserved */
2598c2ecf20Sopenharmony_ci
2608c2ecf20Sopenharmony_ci/* output enables are provided for each device's chip select and for the rest
2618c2ecf20Sopenharmony_ci * of the outputs from cassini to its local bus devices. two sw programmable
2628c2ecf20Sopenharmony_ci * bits are connected to general purpus control/status bits.
2638c2ecf20Sopenharmony_ci * DEFAULT: 0x7
2648c2ecf20Sopenharmony_ci */
2658c2ecf20Sopenharmony_ci#define  REG_BIM_LOCAL_DEV_EN          0x1020  /* BIM local device
2668c2ecf20Sopenharmony_ci						  output EN. default: 0x7 */
2678c2ecf20Sopenharmony_ci#define    BIM_LOCAL_DEV_PAD           0x01    /* address bus, RW signal, and
2688c2ecf20Sopenharmony_ci						  OE signal output enable on the
2698c2ecf20Sopenharmony_ci						  local bus interface. these
2708c2ecf20Sopenharmony_ci						  are shared between both local
2718c2ecf20Sopenharmony_ci						  bus devices. tristate when 0. */
2728c2ecf20Sopenharmony_ci#define    BIM_LOCAL_DEV_PROM          0x02    /* PROM chip select */
2738c2ecf20Sopenharmony_ci#define    BIM_LOCAL_DEV_EXT           0x04    /* secondary local bus device chip
2748c2ecf20Sopenharmony_ci						  select output enable */
2758c2ecf20Sopenharmony_ci#define    BIM_LOCAL_DEV_SOFT_0        0x08    /* sw programmable ctrl bit 0 */
2768c2ecf20Sopenharmony_ci#define    BIM_LOCAL_DEV_SOFT_1        0x10    /* sw programmable ctrl bit 1 */
2778c2ecf20Sopenharmony_ci#define    BIM_LOCAL_DEV_HW_RESET      0x20    /* internal hw reset. Cassini+ only. */
2788c2ecf20Sopenharmony_ci
2798c2ecf20Sopenharmony_ci/* access 24 entry BIM read and write buffers. put address in REG_BIM_BUFFER_ADDR
2808c2ecf20Sopenharmony_ci * and read/write from/to it REG_BIM_BUFFER_DATA_LOW and _DATA_HI.
2818c2ecf20Sopenharmony_ci * _DATA_HI should be the last access of the sequence.
2828c2ecf20Sopenharmony_ci * DEFAULT: undefined
2838c2ecf20Sopenharmony_ci */
2848c2ecf20Sopenharmony_ci#define  REG_BIM_BUFFER_ADDR           0x1024  /* BIM buffer address. for
2858c2ecf20Sopenharmony_ci						  purposes. */
2868c2ecf20Sopenharmony_ci#define    BIM_BUFFER_ADDR_MASK        0x3F    /* index (0 - 23) of buffer  */
2878c2ecf20Sopenharmony_ci#define    BIM_BUFFER_WR_SELECT        0x40    /* write buffer access = 1
2888c2ecf20Sopenharmony_ci						  read buffer access = 0 */
2898c2ecf20Sopenharmony_ci/* DEFAULT: undefined */
2908c2ecf20Sopenharmony_ci#define  REG_BIM_BUFFER_DATA_LOW       0x1028  /* BIM buffer data low */
2918c2ecf20Sopenharmony_ci#define  REG_BIM_BUFFER_DATA_HI        0x102C  /* BIM buffer data high */
2928c2ecf20Sopenharmony_ci
2938c2ecf20Sopenharmony_ci/* set BIM_RAM_BIST_START to start built-in self test for BIM read buffer.
2948c2ecf20Sopenharmony_ci * bit auto-clears when done with status read from _SUMMARY and _PASS bits.
2958c2ecf20Sopenharmony_ci */
2968c2ecf20Sopenharmony_ci#define  REG_BIM_RAM_BIST              0x102C  /* BIM RAM (read buffer) BIST
2978c2ecf20Sopenharmony_ci						  control/status */
2988c2ecf20Sopenharmony_ci#define    BIM_RAM_BIST_RD_START       0x01    /* start BIST for BIM read buffer */
2998c2ecf20Sopenharmony_ci#define    BIM_RAM_BIST_WR_START       0x02    /* start BIST for BIM write buffer.
3008c2ecf20Sopenharmony_ci						  Cassini only. reserved in
3018c2ecf20Sopenharmony_ci						  Cassini+. */
3028c2ecf20Sopenharmony_ci#define    BIM_RAM_BIST_RD_PASS        0x04    /* summary BIST pass status for read
3038c2ecf20Sopenharmony_ci						  buffer. */
3048c2ecf20Sopenharmony_ci#define    BIM_RAM_BIST_WR_PASS        0x08    /* summary BIST pass status for write
3058c2ecf20Sopenharmony_ci						  buffer. Cassini only. reserved
3068c2ecf20Sopenharmony_ci						  in Cassini+. */
3078c2ecf20Sopenharmony_ci#define    BIM_RAM_BIST_RD_LOW_PASS    0x10    /* read low bank passes BIST */
3088c2ecf20Sopenharmony_ci#define    BIM_RAM_BIST_RD_HI_PASS     0x20    /* read high bank passes BIST */
3098c2ecf20Sopenharmony_ci#define    BIM_RAM_BIST_WR_LOW_PASS    0x40    /* write low bank passes BIST.
3108c2ecf20Sopenharmony_ci						  Cassini only. reserved in
3118c2ecf20Sopenharmony_ci						  Cassini+. */
3128c2ecf20Sopenharmony_ci#define    BIM_RAM_BIST_WR_HI_PASS     0x80    /* write high bank passes BIST.
3138c2ecf20Sopenharmony_ci						  Cassini only. reserved in
3148c2ecf20Sopenharmony_ci						  Cassini+. */
3158c2ecf20Sopenharmony_ci
3168c2ecf20Sopenharmony_ci/* ASUN: i'm not sure what this does as it's not in the spec.
3178c2ecf20Sopenharmony_ci * DEFAULT: 0xFC
3188c2ecf20Sopenharmony_ci */
3198c2ecf20Sopenharmony_ci#define  REG_BIM_DIAG_MUX              0x1030  /* BIM diagnostic probe mux
3208c2ecf20Sopenharmony_ci						  select register */
3218c2ecf20Sopenharmony_ci
3228c2ecf20Sopenharmony_ci/* enable probe monitoring mode and select data appearing on the P_A* bus. bit
3238c2ecf20Sopenharmony_ci * values for _SEL_HI_MASK and _SEL_LOW_MASK:
3248c2ecf20Sopenharmony_ci * 0x0: internal probe[7:0] (pci arb state, wtc empty w, wtc full w, wtc empty w,
3258c2ecf20Sopenharmony_ci *                           wtc empty r, post pci)
3268c2ecf20Sopenharmony_ci * 0x1: internal probe[15:8] (pci wbuf comp, pci wpkt comp, pci rbuf comp,
3278c2ecf20Sopenharmony_ci *                            pci rpkt comp, txdma wr req, txdma wr ack,
3288c2ecf20Sopenharmony_ci *			      txdma wr rdy, txdma wr xfr done)
3298c2ecf20Sopenharmony_ci * 0x2: internal probe[23:16] (txdma rd req, txdma rd ack, txdma rd rdy, rxdma rd,
3308c2ecf20Sopenharmony_ci *                             rd arb state, rd pci state)
3318c2ecf20Sopenharmony_ci * 0x3: internal probe[31:24] (rxdma req, rxdma ack, rxdma rdy, wrarb state,
3328c2ecf20Sopenharmony_ci *                             wrpci state)
3338c2ecf20Sopenharmony_ci * 0x4: pci io probe[7:0]     0x5: pci io probe[15:8]
3348c2ecf20Sopenharmony_ci * 0x6: pci io probe[23:16]   0x7: pci io probe[31:24]
3358c2ecf20Sopenharmony_ci * 0x8: pci io probe[39:32]   0x9: pci io probe[47:40]
3368c2ecf20Sopenharmony_ci * 0xa: pci io probe[55:48]   0xb: pci io probe[63:56]
3378c2ecf20Sopenharmony_ci * the following are not available in Cassini:
3388c2ecf20Sopenharmony_ci * 0xc: rx probe[7:0]         0xd: tx probe[7:0]
3398c2ecf20Sopenharmony_ci * 0xe: hp probe[7:0] 	      0xf: mac probe[7:0]
3408c2ecf20Sopenharmony_ci */
3418c2ecf20Sopenharmony_ci#define  REG_PLUS_PROBE_MUX_SELECT     0x1034 /* Cassini+: PROBE MUX SELECT */
3428c2ecf20Sopenharmony_ci#define    PROBE_MUX_EN                0x80000000 /* allow probe signals to be
3438c2ecf20Sopenharmony_ci						     driven on local bus P_A[15:0]
3448c2ecf20Sopenharmony_ci						     for debugging */
3458c2ecf20Sopenharmony_ci#define    PROBE_MUX_SUB_MUX_MASK      0x0000FF00 /* select sub module probe signals:
3468c2ecf20Sopenharmony_ci						     0x03 = mac[1:0]
3478c2ecf20Sopenharmony_ci						     0x0C = rx[1:0]
3488c2ecf20Sopenharmony_ci						     0x30 = tx[1:0]
3498c2ecf20Sopenharmony_ci						     0xC0 = hp[1:0] */
3508c2ecf20Sopenharmony_ci#define    PROBE_MUX_SEL_HI_MASK       0x000000F0 /* select which module to appear
3518c2ecf20Sopenharmony_ci						     on P_A[15:8]. see above for
3528c2ecf20Sopenharmony_ci						     values. */
3538c2ecf20Sopenharmony_ci#define    PROBE_MUX_SEL_LOW_MASK      0x0000000F /* select which module to appear
3548c2ecf20Sopenharmony_ci						     on P_A[7:0]. see above for
3558c2ecf20Sopenharmony_ci						     values. */
3568c2ecf20Sopenharmony_ci
3578c2ecf20Sopenharmony_ci/* values mean the same thing as REG_INTR_MASK excep that it's for INTB.
3588c2ecf20Sopenharmony_ci DEFAULT: 0x1F */
3598c2ecf20Sopenharmony_ci#define  REG_PLUS_INTR_MASK_1          0x1038 /* Cassini+: interrupt mask
3608c2ecf20Sopenharmony_ci						 register 2 for INTB */
3618c2ecf20Sopenharmony_ci#define  REG_PLUS_INTRN_MASK(x)       (REG_PLUS_INTR_MASK_1 + ((x) - 1)*16)
3628c2ecf20Sopenharmony_ci/* bits correspond to both _MASK and _STATUS registers. _ALT corresponds to
3638c2ecf20Sopenharmony_ci * all of the alternate (2-4) INTR registers while _1 corresponds to only
3648c2ecf20Sopenharmony_ci * _MASK_1 and _STATUS_1 registers.
3658c2ecf20Sopenharmony_ci * DEFAULT: 0x7 for MASK registers, 0x0 for ALIAS_CLEAR registers
3668c2ecf20Sopenharmony_ci */
3678c2ecf20Sopenharmony_ci#define    INTR_RX_DONE_ALT              0x01
3688c2ecf20Sopenharmony_ci#define    INTR_RX_COMP_FULL_ALT         0x02
3698c2ecf20Sopenharmony_ci#define    INTR_RX_COMP_AF_ALT           0x04
3708c2ecf20Sopenharmony_ci#define    INTR_RX_BUF_UNAVAIL_1         0x08
3718c2ecf20Sopenharmony_ci#define    INTR_RX_BUF_AE_1              0x10 /* almost empty */
3728c2ecf20Sopenharmony_ci#define    INTRN_MASK_RX_EN              0x80
3738c2ecf20Sopenharmony_ci#define    INTRN_MASK_CLEAR_ALL          (INTR_RX_DONE_ALT | \
3748c2ecf20Sopenharmony_ci                                          INTR_RX_COMP_FULL_ALT | \
3758c2ecf20Sopenharmony_ci                                          INTR_RX_COMP_AF_ALT | \
3768c2ecf20Sopenharmony_ci                                          INTR_RX_BUF_UNAVAIL_1 | \
3778c2ecf20Sopenharmony_ci                                          INTR_RX_BUF_AE_1)
3788c2ecf20Sopenharmony_ci#define  REG_PLUS_INTR_STATUS_1        0x103C /* Cassini+: interrupt status
3798c2ecf20Sopenharmony_ci						 register 2 for INTB. default: 0x1F */
3808c2ecf20Sopenharmony_ci#define  REG_PLUS_INTRN_STATUS(x)       (REG_PLUS_INTR_STATUS_1 + ((x) - 1)*16)
3818c2ecf20Sopenharmony_ci#define    INTR_STATUS_ALT_INTX_EN     0x80   /* generate INTX when one of the
3828c2ecf20Sopenharmony_ci						 flags are set. enables desc ring. */
3838c2ecf20Sopenharmony_ci
3848c2ecf20Sopenharmony_ci#define  REG_PLUS_ALIAS_CLEAR_1        0x1040 /* Cassini+: alias clear mask
3858c2ecf20Sopenharmony_ci						 register 2 for INTB */
3868c2ecf20Sopenharmony_ci#define  REG_PLUS_ALIASN_CLEAR(x)      (REG_PLUS_ALIAS_CLEAR_1 + ((x) - 1)*16)
3878c2ecf20Sopenharmony_ci
3888c2ecf20Sopenharmony_ci#define  REG_PLUS_INTR_STATUS_ALIAS_1  0x1044 /* Cassini+: interrupt status
3898c2ecf20Sopenharmony_ci						 register alias 2 for INTB */
3908c2ecf20Sopenharmony_ci#define  REG_PLUS_INTRN_STATUS_ALIAS(x) (REG_PLUS_INTR_STATUS_ALIAS_1 + ((x) - 1)*16)
3918c2ecf20Sopenharmony_ci
3928c2ecf20Sopenharmony_ci#define REG_SATURN_PCFG               0x106c /* pin configuration register for
3938c2ecf20Sopenharmony_ci						integrated macphy */
3948c2ecf20Sopenharmony_ci
3958c2ecf20Sopenharmony_ci#define   SATURN_PCFG_TLA             0x00000001 /* 1 = phy actled */
3968c2ecf20Sopenharmony_ci#define   SATURN_PCFG_FLA             0x00000002 /* 1 = phy link10led */
3978c2ecf20Sopenharmony_ci#define   SATURN_PCFG_CLA             0x00000004 /* 1 = phy link100led */
3988c2ecf20Sopenharmony_ci#define   SATURN_PCFG_LLA             0x00000008 /* 1 = phy link1000led */
3998c2ecf20Sopenharmony_ci#define   SATURN_PCFG_RLA             0x00000010 /* 1 = phy duplexled */
4008c2ecf20Sopenharmony_ci#define   SATURN_PCFG_PDS             0x00000020 /* phy debug mode.
4018c2ecf20Sopenharmony_ci						    0 = normal */
4028c2ecf20Sopenharmony_ci#define   SATURN_PCFG_MTP             0x00000080 /* test point select */
4038c2ecf20Sopenharmony_ci#define   SATURN_PCFG_GMO             0x00000100 /* GMII observe. 1 =
4048c2ecf20Sopenharmony_ci						    GMII on SERDES pins for
4058c2ecf20Sopenharmony_ci						    monitoring. */
4068c2ecf20Sopenharmony_ci#define   SATURN_PCFG_FSI             0x00000200 /* 1 = freeze serdes/gmii. all
4078c2ecf20Sopenharmony_ci						    pins configed as outputs.
4088c2ecf20Sopenharmony_ci						    for power saving when using
4098c2ecf20Sopenharmony_ci						    internal phy. */
4108c2ecf20Sopenharmony_ci#define   SATURN_PCFG_LAD             0x00000800 /* 0 = mac core led ctrl
4118c2ecf20Sopenharmony_ci						    polarity from strapping
4128c2ecf20Sopenharmony_ci						    value.
4138c2ecf20Sopenharmony_ci						    1 = mac core led ctrl
4148c2ecf20Sopenharmony_ci						    polarity active low. */
4158c2ecf20Sopenharmony_ci
4168c2ecf20Sopenharmony_ci
4178c2ecf20Sopenharmony_ci/** transmit dma registers **/
4188c2ecf20Sopenharmony_ci#define MAX_TX_RINGS_SHIFT            2
4198c2ecf20Sopenharmony_ci#define MAX_TX_RINGS                  (1 << MAX_TX_RINGS_SHIFT)
4208c2ecf20Sopenharmony_ci#define MAX_TX_RINGS_MASK             (MAX_TX_RINGS - 1)
4218c2ecf20Sopenharmony_ci
4228c2ecf20Sopenharmony_ci/* TX configuration.
4238c2ecf20Sopenharmony_ci * descr ring sizes size = 32 * (1 << n), n < 9. e.g., 0x8 = 8k. default: 0x8
4248c2ecf20Sopenharmony_ci * DEFAULT: 0x3F000001
4258c2ecf20Sopenharmony_ci */
4268c2ecf20Sopenharmony_ci#define  REG_TX_CFG                    0x2004  /* TX config */
4278c2ecf20Sopenharmony_ci#define    TX_CFG_DMA_EN               0x00000001  /* enable TX DMA. if cleared, DMA
4288c2ecf20Sopenharmony_ci						      will stop after xfer of current
4298c2ecf20Sopenharmony_ci						      buffer has been completed. */
4308c2ecf20Sopenharmony_ci#define    TX_CFG_FIFO_PIO_SEL         0x00000002  /* TX DMA FIFO can be
4318c2ecf20Sopenharmony_ci						      accessed w/ FIFO addr
4328c2ecf20Sopenharmony_ci						      and data registers.
4338c2ecf20Sopenharmony_ci						      TX DMA should be
4348c2ecf20Sopenharmony_ci						      disabled. */
4358c2ecf20Sopenharmony_ci#define    TX_CFG_DESC_RING0_MASK      0x0000003C  /* # desc entries in
4368c2ecf20Sopenharmony_ci						      ring 1. */
4378c2ecf20Sopenharmony_ci#define    TX_CFG_DESC_RING0_SHIFT     2
4388c2ecf20Sopenharmony_ci#define    TX_CFG_DESC_RINGN_MASK(a)   (TX_CFG_DESC_RING0_MASK << (a)*4)
4398c2ecf20Sopenharmony_ci#define    TX_CFG_DESC_RINGN_SHIFT(a)  (TX_CFG_DESC_RING0_SHIFT + (a)*4)
4408c2ecf20Sopenharmony_ci#define    TX_CFG_PACED_MODE           0x00100000  /* TX_ALL only set after
4418c2ecf20Sopenharmony_ci						      TX FIFO becomes empty.
4428c2ecf20Sopenharmony_ci						      if 0, TX_ALL set
4438c2ecf20Sopenharmony_ci						      if descr queue empty. */
4448c2ecf20Sopenharmony_ci#define    TX_CFG_DMA_RDPIPE_DIS       0x01000000  /* always set to 1 */
4458c2ecf20Sopenharmony_ci#define    TX_CFG_COMPWB_Q1            0x02000000  /* completion writeback happens at
4468c2ecf20Sopenharmony_ci						      the end of every packet kicked
4478c2ecf20Sopenharmony_ci						      through Q1. */
4488c2ecf20Sopenharmony_ci#define    TX_CFG_COMPWB_Q2            0x04000000  /* completion writeback happens at
4498c2ecf20Sopenharmony_ci						      the end of every packet kicked
4508c2ecf20Sopenharmony_ci						      through Q2. */
4518c2ecf20Sopenharmony_ci#define    TX_CFG_COMPWB_Q3            0x08000000  /* completion writeback happens at
4528c2ecf20Sopenharmony_ci						      the end of every packet kicked
4538c2ecf20Sopenharmony_ci						      through Q3 */
4548c2ecf20Sopenharmony_ci#define    TX_CFG_COMPWB_Q4            0x10000000  /* completion writeback happens at
4558c2ecf20Sopenharmony_ci						      the end of every packet kicked
4568c2ecf20Sopenharmony_ci						      through Q4 */
4578c2ecf20Sopenharmony_ci#define    TX_CFG_INTR_COMPWB_DIS      0x20000000  /* disable pre-interrupt completion
4588c2ecf20Sopenharmony_ci						      writeback */
4598c2ecf20Sopenharmony_ci#define    TX_CFG_CTX_SEL_MASK         0xC0000000  /* selects tx test port
4608c2ecf20Sopenharmony_ci						      connection
4618c2ecf20Sopenharmony_ci						      0b00: tx mac req,
4628c2ecf20Sopenharmony_ci						            tx mac retry req,
4638c2ecf20Sopenharmony_ci							    tx ack and tx tag.
4648c2ecf20Sopenharmony_ci						      0b01: txdma rd req,
4658c2ecf20Sopenharmony_ci						            txdma rd ack,
4668c2ecf20Sopenharmony_ci							    txdma rd rdy,
4678c2ecf20Sopenharmony_ci							    txdma rd type0
4688c2ecf20Sopenharmony_ci						      0b11: txdma wr req,
4698c2ecf20Sopenharmony_ci						            txdma wr ack,
4708c2ecf20Sopenharmony_ci							    txdma wr rdy,
4718c2ecf20Sopenharmony_ci							    txdma wr xfr done. */
4728c2ecf20Sopenharmony_ci#define    TX_CFG_CTX_SEL_SHIFT        30
4738c2ecf20Sopenharmony_ci
4748c2ecf20Sopenharmony_ci/* 11-bit counters that point to next location in FIFO to be loaded/retrieved.
4758c2ecf20Sopenharmony_ci * used for diagnostics only.
4768c2ecf20Sopenharmony_ci */
4778c2ecf20Sopenharmony_ci#define  REG_TX_FIFO_WRITE_PTR         0x2014  /* TX FIFO write pointer */
4788c2ecf20Sopenharmony_ci#define  REG_TX_FIFO_SHADOW_WRITE_PTR  0x2018  /* TX FIFO shadow write
4798c2ecf20Sopenharmony_ci						  pointer. temp hold reg.
4808c2ecf20Sopenharmony_ci					          diagnostics only. */
4818c2ecf20Sopenharmony_ci#define  REG_TX_FIFO_READ_PTR          0x201C  /* TX FIFO read pointer */
4828c2ecf20Sopenharmony_ci#define  REG_TX_FIFO_SHADOW_READ_PTR   0x2020  /* TX FIFO shadow read
4838c2ecf20Sopenharmony_ci						  pointer */
4848c2ecf20Sopenharmony_ci
4858c2ecf20Sopenharmony_ci/* (ro) 11-bit up/down counter w/ # of frames currently in TX FIFO */
4868c2ecf20Sopenharmony_ci#define  REG_TX_FIFO_PKT_CNT           0x2024  /* TX FIFO packet counter */
4878c2ecf20Sopenharmony_ci
4888c2ecf20Sopenharmony_ci/* current state of all state machines in TX */
4898c2ecf20Sopenharmony_ci#define  REG_TX_SM_1                   0x2028  /* TX state machine reg #1 */
4908c2ecf20Sopenharmony_ci#define    TX_SM_1_CHAIN_MASK          0x000003FF   /* chaining state machine */
4918c2ecf20Sopenharmony_ci#define    TX_SM_1_CSUM_MASK           0x00000C00   /* checksum state machine */
4928c2ecf20Sopenharmony_ci#define    TX_SM_1_FIFO_LOAD_MASK      0x0003F000   /* FIFO load state machine.
4938c2ecf20Sopenharmony_ci						       = 0x01 when TX disabled. */
4948c2ecf20Sopenharmony_ci#define    TX_SM_1_FIFO_UNLOAD_MASK    0x003C0000   /* FIFO unload state machine */
4958c2ecf20Sopenharmony_ci#define    TX_SM_1_CACHE_MASK          0x03C00000   /* desc. prefetch cache controller
4968c2ecf20Sopenharmony_ci						       state machine */
4978c2ecf20Sopenharmony_ci#define    TX_SM_1_CBQ_ARB_MASK        0xF8000000   /* CBQ arbiter state machine */
4988c2ecf20Sopenharmony_ci
4998c2ecf20Sopenharmony_ci#define  REG_TX_SM_2                   0x202C  /* TX state machine reg #2 */
5008c2ecf20Sopenharmony_ci#define    TX_SM_2_COMP_WB_MASK        0x07    /* completion writeback sm */
5018c2ecf20Sopenharmony_ci#define	   TX_SM_2_SUB_LOAD_MASK       0x38    /* sub load state machine */
5028c2ecf20Sopenharmony_ci#define	   TX_SM_2_KICK_MASK           0xC0    /* kick state machine */
5038c2ecf20Sopenharmony_ci
5048c2ecf20Sopenharmony_ci/* 64-bit pointer to the transmit data buffer. only the 50 LSB are incremented
5058c2ecf20Sopenharmony_ci * while the upper 23 bits are taken from the TX descriptor
5068c2ecf20Sopenharmony_ci */
5078c2ecf20Sopenharmony_ci#define  REG_TX_DATA_PTR_LOW           0x2030  /* TX data pointer low */
5088c2ecf20Sopenharmony_ci#define  REG_TX_DATA_PTR_HI            0x2034  /* TX data pointer high */
5098c2ecf20Sopenharmony_ci
5108c2ecf20Sopenharmony_ci/* 13 bit registers written by driver w/ descriptor value that follows
5118c2ecf20Sopenharmony_ci * last valid xmit descriptor. kick # and complete # values are used by
5128c2ecf20Sopenharmony_ci * the xmit dma engine to control tx descr fetching. if > 1 valid
5138c2ecf20Sopenharmony_ci * tx descr is available within the cache line being read, cassini will
5148c2ecf20Sopenharmony_ci * internally cache up to 4 of them. 0 on reset. _KICK = rw, _COMP = ro.
5158c2ecf20Sopenharmony_ci */
5168c2ecf20Sopenharmony_ci#define  REG_TX_KICK0                  0x2038  /* TX kick reg #1 */
5178c2ecf20Sopenharmony_ci#define  REG_TX_KICKN(x)               (REG_TX_KICK0 + (x)*4)
5188c2ecf20Sopenharmony_ci#define  REG_TX_COMP0                  0x2048  /* TX completion reg #1 */
5198c2ecf20Sopenharmony_ci#define  REG_TX_COMPN(x)               (REG_TX_COMP0 + (x)*4)
5208c2ecf20Sopenharmony_ci
5218c2ecf20Sopenharmony_ci/* values of TX_COMPLETE_1-4 are written. each completion register
5228c2ecf20Sopenharmony_ci * is 2bytes in size and contiguous. 8B allocation w/ 8B alignment.
5238c2ecf20Sopenharmony_ci * NOTE: completion reg values are only written back prior to TX_INTME and
5248c2ecf20Sopenharmony_ci * TX_ALL interrupts. at all other times, the most up-to-date index values
5258c2ecf20Sopenharmony_ci * should be obtained from the REG_TX_COMPLETE_# registers.
5268c2ecf20Sopenharmony_ci * here's the layout:
5278c2ecf20Sopenharmony_ci * offset from base addr      completion # byte
5288c2ecf20Sopenharmony_ci *           0                TX_COMPLETE_1_MSB
5298c2ecf20Sopenharmony_ci *	     1                TX_COMPLETE_1_LSB
5308c2ecf20Sopenharmony_ci *           2                TX_COMPLETE_2_MSB
5318c2ecf20Sopenharmony_ci *	     3                TX_COMPLETE_2_LSB
5328c2ecf20Sopenharmony_ci *           4                TX_COMPLETE_3_MSB
5338c2ecf20Sopenharmony_ci *	     5                TX_COMPLETE_3_LSB
5348c2ecf20Sopenharmony_ci *           6                TX_COMPLETE_4_MSB
5358c2ecf20Sopenharmony_ci *	     7                TX_COMPLETE_4_LSB
5368c2ecf20Sopenharmony_ci */
5378c2ecf20Sopenharmony_ci#define  TX_COMPWB_SIZE             8
5388c2ecf20Sopenharmony_ci#define  REG_TX_COMPWB_DB_LOW       0x2058  /* TX completion write back
5398c2ecf20Sopenharmony_ci					       base low */
5408c2ecf20Sopenharmony_ci#define  REG_TX_COMPWB_DB_HI        0x205C  /* TX completion write back
5418c2ecf20Sopenharmony_ci					       base high */
5428c2ecf20Sopenharmony_ci#define    TX_COMPWB_MSB_MASK       0x00000000000000FFULL
5438c2ecf20Sopenharmony_ci#define    TX_COMPWB_MSB_SHIFT      0
5448c2ecf20Sopenharmony_ci#define    TX_COMPWB_LSB_MASK       0x000000000000FF00ULL
5458c2ecf20Sopenharmony_ci#define    TX_COMPWB_LSB_SHIFT      8
5468c2ecf20Sopenharmony_ci#define    TX_COMPWB_NEXT(x)        ((x) >> 16)
5478c2ecf20Sopenharmony_ci
5488c2ecf20Sopenharmony_ci/* 53 MSB used as base address. 11 LSB assumed to be 0. TX desc pointer must
5498c2ecf20Sopenharmony_ci * be 2KB-aligned. */
5508c2ecf20Sopenharmony_ci#define  REG_TX_DB0_LOW         0x2060  /* TX descriptor base low #1 */
5518c2ecf20Sopenharmony_ci#define  REG_TX_DB0_HI          0x2064  /* TX descriptor base hi #1 */
5528c2ecf20Sopenharmony_ci#define  REG_TX_DBN_LOW(x)      (REG_TX_DB0_LOW + (x)*8)
5538c2ecf20Sopenharmony_ci#define  REG_TX_DBN_HI(x)       (REG_TX_DB0_HI + (x)*8)
5548c2ecf20Sopenharmony_ci
5558c2ecf20Sopenharmony_ci/* 16-bit registers hold weights for the weighted round-robin of the
5568c2ecf20Sopenharmony_ci * four CBQ TX descr rings. weights correspond to # bytes xferred from
5578c2ecf20Sopenharmony_ci * host to TXFIFO in a round of WRR arbitration. can be set
5588c2ecf20Sopenharmony_ci * dynamically with new weights set upon completion of the current
5598c2ecf20Sopenharmony_ci * packet transfer from host memory to TXFIFO. a dummy write to any of
5608c2ecf20Sopenharmony_ci * these registers causes a queue1 pre-emption with all historical bw
5618c2ecf20Sopenharmony_ci * deficit data reset to 0 (useful when congestion requires a
5628c2ecf20Sopenharmony_ci * pre-emption/re-allocation of network bandwidth
5638c2ecf20Sopenharmony_ci */
5648c2ecf20Sopenharmony_ci#define  REG_TX_MAXBURST_0             0x2080  /* TX MaxBurst #1 */
5658c2ecf20Sopenharmony_ci#define  REG_TX_MAXBURST_1             0x2084  /* TX MaxBurst #2 */
5668c2ecf20Sopenharmony_ci#define  REG_TX_MAXBURST_2             0x2088  /* TX MaxBurst #3 */
5678c2ecf20Sopenharmony_ci#define  REG_TX_MAXBURST_3             0x208C  /* TX MaxBurst #4 */
5688c2ecf20Sopenharmony_ci
5698c2ecf20Sopenharmony_ci/* diagnostics access to any TX FIFO location. every access is 65
5708c2ecf20Sopenharmony_ci * bits.  _DATA_LOW = 32 LSB, _DATA_HI_T1/T0 = 32 MSB. _TAG = tag bit.
5718c2ecf20Sopenharmony_ci * writing _DATA_HI_T0 sets tag bit low, writing _DATA_HI_T1 sets tag
5728c2ecf20Sopenharmony_ci * bit high.  TX_FIFO_PIO_SEL must be set for TX FIFO PIO access. if
5738c2ecf20Sopenharmony_ci * TX FIFO data integrity is desired, TX DMA should be
5748c2ecf20Sopenharmony_ci * disabled. _DATA_HI_Tx should be the last access of the sequence.
5758c2ecf20Sopenharmony_ci */
5768c2ecf20Sopenharmony_ci#define  REG_TX_FIFO_ADDR              0x2104  /* TX FIFO address */
5778c2ecf20Sopenharmony_ci#define  REG_TX_FIFO_TAG               0x2108  /* TX FIFO tag */
5788c2ecf20Sopenharmony_ci#define  REG_TX_FIFO_DATA_LOW          0x210C  /* TX FIFO data low */
5798c2ecf20Sopenharmony_ci#define  REG_TX_FIFO_DATA_HI_T1        0x2110  /* TX FIFO data high t1 */
5808c2ecf20Sopenharmony_ci#define  REG_TX_FIFO_DATA_HI_T0        0x2114  /* TX FIFO data high t0 */
5818c2ecf20Sopenharmony_ci#define  REG_TX_FIFO_SIZE              0x2118  /* (ro) TX FIFO size = 0x090 = 9KB */
5828c2ecf20Sopenharmony_ci
5838c2ecf20Sopenharmony_ci/* 9-bit register controls BIST of TX FIFO. bit set indicates that the BIST
5848c2ecf20Sopenharmony_ci * passed for the specified memory
5858c2ecf20Sopenharmony_ci */
5868c2ecf20Sopenharmony_ci#define  REG_TX_RAMBIST                0x211C /* TX RAMBIST control/status */
5878c2ecf20Sopenharmony_ci#define    TX_RAMBIST_STATE            0x01C0 /* progress state of RAMBIST
5888c2ecf20Sopenharmony_ci						 controller state machine */
5898c2ecf20Sopenharmony_ci#define    TX_RAMBIST_RAM33A_PASS      0x0020 /* RAM33A passed */
5908c2ecf20Sopenharmony_ci#define    TX_RAMBIST_RAM32A_PASS      0x0010 /* RAM32A passed */
5918c2ecf20Sopenharmony_ci#define    TX_RAMBIST_RAM33B_PASS      0x0008 /* RAM33B passed */
5928c2ecf20Sopenharmony_ci#define    TX_RAMBIST_RAM32B_PASS      0x0004 /* RAM32B passed */
5938c2ecf20Sopenharmony_ci#define    TX_RAMBIST_SUMMARY          0x0002 /* all RAM passed */
5948c2ecf20Sopenharmony_ci#define    TX_RAMBIST_START            0x0001 /* write 1 to start BIST. self
5958c2ecf20Sopenharmony_ci						 clears on completion. */
5968c2ecf20Sopenharmony_ci
5978c2ecf20Sopenharmony_ci/** receive dma registers **/
5988c2ecf20Sopenharmony_ci#define MAX_RX_DESC_RINGS              2
5998c2ecf20Sopenharmony_ci#define MAX_RX_COMP_RINGS              4
6008c2ecf20Sopenharmony_ci
6018c2ecf20Sopenharmony_ci/* receive DMA channel configuration. default: 0x80910
6028c2ecf20Sopenharmony_ci * free ring size       = (1 << n)*32  -> [32 - 8k]
6038c2ecf20Sopenharmony_ci * completion ring size = (1 << n)*128 -> [128 - 32k], n < 9
6048c2ecf20Sopenharmony_ci * DEFAULT: 0x80910
6058c2ecf20Sopenharmony_ci */
6068c2ecf20Sopenharmony_ci#define  REG_RX_CFG                     0x4000  /* RX config */
6078c2ecf20Sopenharmony_ci#define    RX_CFG_DMA_EN                0x00000001 /* enable RX DMA. 0 stops
6088c2ecf20Sopenharmony_ci							 channel as soon as current
6098c2ecf20Sopenharmony_ci							 frame xfer has completed.
6108c2ecf20Sopenharmony_ci							 driver should disable MAC
6118c2ecf20Sopenharmony_ci							 for 200ms before disabling
6128c2ecf20Sopenharmony_ci							 RX */
6138c2ecf20Sopenharmony_ci#define    RX_CFG_DESC_RING_MASK        0x0000001E /* # desc entries in RX
6148c2ecf20Sopenharmony_ci							 free desc ring.
6158c2ecf20Sopenharmony_ci							 def: 0x8 = 8k */
6168c2ecf20Sopenharmony_ci#define    RX_CFG_DESC_RING_SHIFT       1
6178c2ecf20Sopenharmony_ci#define    RX_CFG_COMP_RING_MASK        0x000001E0 /* # desc entries in RX complete
6188c2ecf20Sopenharmony_ci							 ring. def: 0x8 = 32k */
6198c2ecf20Sopenharmony_ci#define    RX_CFG_COMP_RING_SHIFT       5
6208c2ecf20Sopenharmony_ci#define    RX_CFG_BATCH_DIS             0x00000200 /* disable receive desc
6218c2ecf20Sopenharmony_ci						      batching. def: 0x0 =
6228c2ecf20Sopenharmony_ci						      enabled */
6238c2ecf20Sopenharmony_ci#define    RX_CFG_SWIVEL_MASK           0x00001C00 /* byte offset of the 1st
6248c2ecf20Sopenharmony_ci						      data byte of the packet
6258c2ecf20Sopenharmony_ci						      w/in 8 byte boundares.
6268c2ecf20Sopenharmony_ci						      this swivels the data
6278c2ecf20Sopenharmony_ci						      DMA'ed to header
6288c2ecf20Sopenharmony_ci						      buffers, jumbo buffers
6298c2ecf20Sopenharmony_ci						      when header split is not
6308c2ecf20Sopenharmony_ci						      requested and MTU sized
6318c2ecf20Sopenharmony_ci						      buffers. def: 0x2 */
6328c2ecf20Sopenharmony_ci#define    RX_CFG_SWIVEL_SHIFT          10
6338c2ecf20Sopenharmony_ci
6348c2ecf20Sopenharmony_ci/* cassini+ only */
6358c2ecf20Sopenharmony_ci#define    RX_CFG_DESC_RING1_MASK       0x000F0000 /* # of desc entries in
6368c2ecf20Sopenharmony_ci							 RX free desc ring 2.
6378c2ecf20Sopenharmony_ci							 def: 0x8 = 8k */
6388c2ecf20Sopenharmony_ci#define    RX_CFG_DESC_RING1_SHIFT      16
6398c2ecf20Sopenharmony_ci
6408c2ecf20Sopenharmony_ci
6418c2ecf20Sopenharmony_ci/* the page size register allows cassini chips to do the following with
6428c2ecf20Sopenharmony_ci * received data:
6438c2ecf20Sopenharmony_ci * [--------------------------------------------------------------] page
6448c2ecf20Sopenharmony_ci * [off][buf1][pad][off][buf2][pad][off][buf3][pad][off][buf4][pad]
6458c2ecf20Sopenharmony_ci * |--------------| = PAGE_SIZE_BUFFER_STRIDE
6468c2ecf20Sopenharmony_ci * page = PAGE_SIZE
6478c2ecf20Sopenharmony_ci * offset = PAGE_SIZE_MTU_OFF
6488c2ecf20Sopenharmony_ci * for the above example, MTU_BUFFER_COUNT = 4.
6498c2ecf20Sopenharmony_ci * NOTE: as is apparent, you need to ensure that the following holds:
6508c2ecf20Sopenharmony_ci * MTU_BUFFER_COUNT <= PAGE_SIZE/PAGE_SIZE_BUFFER_STRIDE
6518c2ecf20Sopenharmony_ci * DEFAULT: 0x48002002 (8k pages)
6528c2ecf20Sopenharmony_ci */
6538c2ecf20Sopenharmony_ci#define  REG_RX_PAGE_SIZE               0x4004  /* RX page size */
6548c2ecf20Sopenharmony_ci#define    RX_PAGE_SIZE_MASK            0x00000003 /* size of pages pointed to
6558c2ecf20Sopenharmony_ci						      by receive descriptors.
6568c2ecf20Sopenharmony_ci						      if jumbo buffers are
6578c2ecf20Sopenharmony_ci						      supported the page size
6588c2ecf20Sopenharmony_ci						      should not be < 8k.
6598c2ecf20Sopenharmony_ci						      0b00 = 2k, 0b01 = 4k
6608c2ecf20Sopenharmony_ci						      0b10 = 8k, 0b11 = 16k
6618c2ecf20Sopenharmony_ci						      DEFAULT: 8k */
6628c2ecf20Sopenharmony_ci#define    RX_PAGE_SIZE_SHIFT           0
6638c2ecf20Sopenharmony_ci#define    RX_PAGE_SIZE_MTU_COUNT_MASK  0x00007800 /* # of MTU buffers the hw
6648c2ecf20Sopenharmony_ci						      packs into a page.
6658c2ecf20Sopenharmony_ci						      DEFAULT: 4 */
6668c2ecf20Sopenharmony_ci#define    RX_PAGE_SIZE_MTU_COUNT_SHIFT 11
6678c2ecf20Sopenharmony_ci#define    RX_PAGE_SIZE_MTU_STRIDE_MASK 0x18000000 /* # of bytes that separate
6688c2ecf20Sopenharmony_ci							 each MTU buffer +
6698c2ecf20Sopenharmony_ci							 offset from each
6708c2ecf20Sopenharmony_ci							 other.
6718c2ecf20Sopenharmony_ci							 0b00 = 1k, 0b01 = 2k
6728c2ecf20Sopenharmony_ci							 0b10 = 4k, 0b11 = 8k
6738c2ecf20Sopenharmony_ci							 DEFAULT: 0x1 */
6748c2ecf20Sopenharmony_ci#define    RX_PAGE_SIZE_MTU_STRIDE_SHIFT 27
6758c2ecf20Sopenharmony_ci#define    RX_PAGE_SIZE_MTU_OFF_MASK    0xC0000000 /* offset in each page that
6768c2ecf20Sopenharmony_ci						      hw writes the MTU buffer
6778c2ecf20Sopenharmony_ci						      into.
6788c2ecf20Sopenharmony_ci						      0b00 = 0,
6798c2ecf20Sopenharmony_ci						      0b01 = 64 bytes
6808c2ecf20Sopenharmony_ci						      0b10 = 96, 0b11 = 128
6818c2ecf20Sopenharmony_ci						      DEFAULT: 0x1 */
6828c2ecf20Sopenharmony_ci#define    RX_PAGE_SIZE_MTU_OFF_SHIFT   30
6838c2ecf20Sopenharmony_ci
6848c2ecf20Sopenharmony_ci/* 11-bit counter points to next location in RX FIFO to be loaded/read.
6858c2ecf20Sopenharmony_ci * shadow write pointers enable retries in case of early receive aborts.
6868c2ecf20Sopenharmony_ci * DEFAULT: 0x0. generated on 64-bit boundaries.
6878c2ecf20Sopenharmony_ci */
6888c2ecf20Sopenharmony_ci#define  REG_RX_FIFO_WRITE_PTR             0x4008  /* RX FIFO write pointer */
6898c2ecf20Sopenharmony_ci#define  REG_RX_FIFO_READ_PTR              0x400C  /* RX FIFO read pointer */
6908c2ecf20Sopenharmony_ci#define  REG_RX_IPP_FIFO_SHADOW_WRITE_PTR  0x4010  /* RX IPP FIFO shadow write
6918c2ecf20Sopenharmony_ci						      pointer */
6928c2ecf20Sopenharmony_ci#define  REG_RX_IPP_FIFO_SHADOW_READ_PTR   0x4014  /* RX IPP FIFO shadow read
6938c2ecf20Sopenharmony_ci						      pointer */
6948c2ecf20Sopenharmony_ci#define  REG_RX_IPP_FIFO_READ_PTR          0x400C  /* RX IPP FIFO read
6958c2ecf20Sopenharmony_ci						      pointer. (8-bit counter) */
6968c2ecf20Sopenharmony_ci
6978c2ecf20Sopenharmony_ci/* current state of RX DMA state engines + other info
6988c2ecf20Sopenharmony_ci * DEFAULT: 0x0
6998c2ecf20Sopenharmony_ci */
7008c2ecf20Sopenharmony_ci#define  REG_RX_DEBUG                      0x401C  /* RX debug */
7018c2ecf20Sopenharmony_ci#define    RX_DEBUG_LOAD_STATE_MASK        0x0000000F /* load state machine w/ MAC:
7028c2ecf20Sopenharmony_ci							 0x0 = idle,   0x1 = load_bop
7038c2ecf20Sopenharmony_ci							 0x2 = load 1, 0x3 = load 2
7048c2ecf20Sopenharmony_ci							 0x4 = load 3, 0x5 = load 4
7058c2ecf20Sopenharmony_ci							 0x6 = last detect
7068c2ecf20Sopenharmony_ci							 0x7 = wait req
7078c2ecf20Sopenharmony_ci							 0x8 = wait req statuss 1st
7088c2ecf20Sopenharmony_ci							 0x9 = load st
7098c2ecf20Sopenharmony_ci							 0xa = bubble mac
7108c2ecf20Sopenharmony_ci							 0xb = error */
7118c2ecf20Sopenharmony_ci#define    RX_DEBUG_LM_STATE_MASK          0x00000070 /* load state machine w/ HP and
7128c2ecf20Sopenharmony_ci							 RX FIFO:
7138c2ecf20Sopenharmony_ci							 0x0 = idle,   0x1 = hp xfr
7148c2ecf20Sopenharmony_ci							 0x2 = wait hp ready
7158c2ecf20Sopenharmony_ci							 0x3 = wait flow code
7168c2ecf20Sopenharmony_ci							 0x4 = fifo xfer
7178c2ecf20Sopenharmony_ci							 0x5 = make status
7188c2ecf20Sopenharmony_ci							 0x6 = csum ready
7198c2ecf20Sopenharmony_ci							 0x7 = error */
7208c2ecf20Sopenharmony_ci#define    RX_DEBUG_FC_STATE_MASK          0x000000180 /* flow control state machine
7218c2ecf20Sopenharmony_ci							 w/ MAC:
7228c2ecf20Sopenharmony_ci							 0x0 = idle
7238c2ecf20Sopenharmony_ci							 0x1 = wait xoff ack
7248c2ecf20Sopenharmony_ci							 0x2 = wait xon
7258c2ecf20Sopenharmony_ci							 0x3 = wait xon ack */
7268c2ecf20Sopenharmony_ci#define    RX_DEBUG_DATA_STATE_MASK        0x000001E00 /* unload data state machine
7278c2ecf20Sopenharmony_ci							 states:
7288c2ecf20Sopenharmony_ci							 0x0 = idle data
7298c2ecf20Sopenharmony_ci							 0x1 = header begin
7308c2ecf20Sopenharmony_ci							 0x2 = xfer header
7318c2ecf20Sopenharmony_ci							 0x3 = xfer header ld
7328c2ecf20Sopenharmony_ci							 0x4 = mtu begin
7338c2ecf20Sopenharmony_ci							 0x5 = xfer mtu
7348c2ecf20Sopenharmony_ci							 0x6 = xfer mtu ld
7358c2ecf20Sopenharmony_ci							 0x7 = jumbo begin
7368c2ecf20Sopenharmony_ci							 0x8 = xfer jumbo
7378c2ecf20Sopenharmony_ci							 0x9 = xfer jumbo ld
7388c2ecf20Sopenharmony_ci							 0xa = reas begin
7398c2ecf20Sopenharmony_ci							 0xb = xfer reas
7408c2ecf20Sopenharmony_ci							 0xc = flush tag
7418c2ecf20Sopenharmony_ci							 0xd = xfer reas ld
7428c2ecf20Sopenharmony_ci							 0xe = error
7438c2ecf20Sopenharmony_ci							 0xf = bubble idle */
7448c2ecf20Sopenharmony_ci#define    RX_DEBUG_DESC_STATE_MASK        0x0001E000 /* unload desc state machine
7458c2ecf20Sopenharmony_ci							 states:
7468c2ecf20Sopenharmony_ci							 0x0 = idle desc
7478c2ecf20Sopenharmony_ci							 0x1 = wait ack
7488c2ecf20Sopenharmony_ci							 0x9 = wait ack 2
7498c2ecf20Sopenharmony_ci							 0x2 = fetch desc 1
7508c2ecf20Sopenharmony_ci							 0xa = fetch desc 2
7518c2ecf20Sopenharmony_ci							 0x3 = load ptrs
7528c2ecf20Sopenharmony_ci							 0x4 = wait dma
7538c2ecf20Sopenharmony_ci							 0x5 = wait ack batch
7548c2ecf20Sopenharmony_ci							 0x6 = post batch
7558c2ecf20Sopenharmony_ci							 0x7 = xfr done */
7568c2ecf20Sopenharmony_ci#define    RX_DEBUG_INTR_READ_PTR_MASK     0x30000000 /* interrupt read ptr of the
7578c2ecf20Sopenharmony_ci							 interrupt queue */
7588c2ecf20Sopenharmony_ci#define    RX_DEBUG_INTR_WRITE_PTR_MASK    0xC0000000 /* interrupt write pointer
7598c2ecf20Sopenharmony_ci							 of the interrupt queue */
7608c2ecf20Sopenharmony_ci
7618c2ecf20Sopenharmony_ci/* flow control frames are emitted using two PAUSE thresholds:
7628c2ecf20Sopenharmony_ci * XOFF PAUSE uses pause time value pre-programmed in the Send PAUSE MAC reg
7638c2ecf20Sopenharmony_ci * XON PAUSE uses a pause time of 0. granularity of threshold is 64bytes.
7648c2ecf20Sopenharmony_ci * PAUSE thresholds defined in terms of FIFO occupancy and may be translated
7658c2ecf20Sopenharmony_ci * into FIFO vacancy using RX_FIFO_SIZE. setting ON will trigger XON frames
7668c2ecf20Sopenharmony_ci * when FIFO reaches 0. OFF threshold should not be > size of RX FIFO. max
7678c2ecf20Sopenharmony_ci * value is is 0x6F.
7688c2ecf20Sopenharmony_ci * DEFAULT: 0x00078
7698c2ecf20Sopenharmony_ci */
7708c2ecf20Sopenharmony_ci#define  REG_RX_PAUSE_THRESH               0x4020  /* RX pause thresholds */
7718c2ecf20Sopenharmony_ci#define    RX_PAUSE_THRESH_QUANTUM         64
7728c2ecf20Sopenharmony_ci#define    RX_PAUSE_THRESH_OFF_MASK        0x000001FF /* XOFF PAUSE emitted when
7738c2ecf20Sopenharmony_ci							 RX FIFO occupancy >
7748c2ecf20Sopenharmony_ci							 value*64B */
7758c2ecf20Sopenharmony_ci#define    RX_PAUSE_THRESH_OFF_SHIFT       0
7768c2ecf20Sopenharmony_ci#define    RX_PAUSE_THRESH_ON_MASK         0x001FF000 /* XON PAUSE emitted after
7778c2ecf20Sopenharmony_ci							 emitting XOFF PAUSE when RX
7788c2ecf20Sopenharmony_ci							 FIFO occupancy falls below
7798c2ecf20Sopenharmony_ci							 this value*64B. must be
7808c2ecf20Sopenharmony_ci							 < XOFF threshold. if =
7818c2ecf20Sopenharmony_ci							 RX_FIFO_SIZE< XON frames are
7828c2ecf20Sopenharmony_ci							 never emitted. */
7838c2ecf20Sopenharmony_ci#define    RX_PAUSE_THRESH_ON_SHIFT        12
7848c2ecf20Sopenharmony_ci
7858c2ecf20Sopenharmony_ci/* 13-bit register used to control RX desc fetching and intr generation. if 4+
7868c2ecf20Sopenharmony_ci * valid RX descriptors are available, Cassini will read 4 at a time.
7878c2ecf20Sopenharmony_ci * writing N means that all desc up to *but* excluding N are available. N must
7888c2ecf20Sopenharmony_ci * be a multiple of 4 (N % 4 = 0). first desc should be cache-line aligned.
7898c2ecf20Sopenharmony_ci * DEFAULT: 0 on reset
7908c2ecf20Sopenharmony_ci */
7918c2ecf20Sopenharmony_ci#define  REG_RX_KICK                    0x4024  /* RX kick reg */
7928c2ecf20Sopenharmony_ci
7938c2ecf20Sopenharmony_ci/* 8KB aligned 64-bit pointer to the base of the RX free/completion rings.
7948c2ecf20Sopenharmony_ci * lower 13 bits of the low register are hard-wired to 0.
7958c2ecf20Sopenharmony_ci */
7968c2ecf20Sopenharmony_ci#define  REG_RX_DB_LOW                     0x4028  /* RX descriptor ring
7978c2ecf20Sopenharmony_ci							 base low */
7988c2ecf20Sopenharmony_ci#define  REG_RX_DB_HI                      0x402C  /* RX descriptor ring
7998c2ecf20Sopenharmony_ci							 base hi */
8008c2ecf20Sopenharmony_ci#define  REG_RX_CB_LOW                     0x4030  /* RX completion ring
8018c2ecf20Sopenharmony_ci							 base low */
8028c2ecf20Sopenharmony_ci#define  REG_RX_CB_HI                      0x4034  /* RX completion ring
8038c2ecf20Sopenharmony_ci							 base hi */
8048c2ecf20Sopenharmony_ci/* 13-bit register indicate desc used by cassini for receive frames. used
8058c2ecf20Sopenharmony_ci * for diagnostic purposes.
8068c2ecf20Sopenharmony_ci * DEFAULT: 0 on reset
8078c2ecf20Sopenharmony_ci */
8088c2ecf20Sopenharmony_ci#define  REG_RX_COMP                       0x4038  /* (ro) RX completion */
8098c2ecf20Sopenharmony_ci
8108c2ecf20Sopenharmony_ci/* HEAD and TAIL are used to control RX desc posting and interrupt
8118c2ecf20Sopenharmony_ci * generation.  hw moves the head register to pass ownership to sw. sw
8128c2ecf20Sopenharmony_ci * moves the tail register to pass ownership back to hw. to give all
8138c2ecf20Sopenharmony_ci * entries to hw, set TAIL = HEAD.  if HEAD and TAIL indicate that no
8148c2ecf20Sopenharmony_ci * more entries are available, DMA will pause and an interrupt will be
8158c2ecf20Sopenharmony_ci * generated to indicate no more entries are available.  sw can use
8168c2ecf20Sopenharmony_ci * this interrupt to reduce the # of times it must update the
8178c2ecf20Sopenharmony_ci * completion tail register.
8188c2ecf20Sopenharmony_ci * DEFAULT: 0 on reset
8198c2ecf20Sopenharmony_ci */
8208c2ecf20Sopenharmony_ci#define  REG_RX_COMP_HEAD                  0x403C  /* RX completion head */
8218c2ecf20Sopenharmony_ci#define  REG_RX_COMP_TAIL                  0x4040  /* RX completion tail */
8228c2ecf20Sopenharmony_ci
8238c2ecf20Sopenharmony_ci/* values used for receive interrupt blanking. loaded each time the ISR is read
8248c2ecf20Sopenharmony_ci * DEFAULT: 0x00000000
8258c2ecf20Sopenharmony_ci */
8268c2ecf20Sopenharmony_ci#define  REG_RX_BLANK                      0x4044  /* RX blanking register
8278c2ecf20Sopenharmony_ci							 for ISR read */
8288c2ecf20Sopenharmony_ci#define    RX_BLANK_INTR_PKT_MASK          0x000001FF /* RX_DONE intr asserted if
8298c2ecf20Sopenharmony_ci							 this many sets of completion
8308c2ecf20Sopenharmony_ci							 writebacks (up to 2 packets)
8318c2ecf20Sopenharmony_ci							 occur since the last time
8328c2ecf20Sopenharmony_ci							 the ISR was read. 0 = no
8338c2ecf20Sopenharmony_ci							 packet blanking */
8348c2ecf20Sopenharmony_ci#define    RX_BLANK_INTR_PKT_SHIFT         0
8358c2ecf20Sopenharmony_ci#define    RX_BLANK_INTR_TIME_MASK         0x3FFFF000 /* RX_DONE interrupt asserted
8368c2ecf20Sopenharmony_ci							 if that many clocks were
8378c2ecf20Sopenharmony_ci							 counted since last time the
8388c2ecf20Sopenharmony_ci							 ISR was read.
8398c2ecf20Sopenharmony_ci							 each count is 512 core
8408c2ecf20Sopenharmony_ci							 clocks (125MHz). 0 = no
8418c2ecf20Sopenharmony_ci							 time blanking */
8428c2ecf20Sopenharmony_ci#define    RX_BLANK_INTR_TIME_SHIFT        12
8438c2ecf20Sopenharmony_ci
8448c2ecf20Sopenharmony_ci/* values used for interrupt generation based on threshold values of how
8458c2ecf20Sopenharmony_ci * many free desc and completion entries are available for hw use.
8468c2ecf20Sopenharmony_ci * DEFAULT: 0x00000000
8478c2ecf20Sopenharmony_ci */
8488c2ecf20Sopenharmony_ci#define  REG_RX_AE_THRESH                  0x4048  /* RX almost empty
8498c2ecf20Sopenharmony_ci							 thresholds */
8508c2ecf20Sopenharmony_ci#define    RX_AE_THRESH_FREE_MASK          0x00001FFF /* RX_BUF_AE will be
8518c2ecf20Sopenharmony_ci							 generated if # desc
8528c2ecf20Sopenharmony_ci							 avail for hw use <=
8538c2ecf20Sopenharmony_ci							 # */
8548c2ecf20Sopenharmony_ci#define    RX_AE_THRESH_FREE_SHIFT         0
8558c2ecf20Sopenharmony_ci#define    RX_AE_THRESH_COMP_MASK          0x0FFFE000 /* RX_COMP_AE will be
8568c2ecf20Sopenharmony_ci							 generated if # of
8578c2ecf20Sopenharmony_ci							 completion entries
8588c2ecf20Sopenharmony_ci							 avail for hw use <=
8598c2ecf20Sopenharmony_ci							 # */
8608c2ecf20Sopenharmony_ci#define    RX_AE_THRESH_COMP_SHIFT         13
8618c2ecf20Sopenharmony_ci
8628c2ecf20Sopenharmony_ci/* probabilities for random early drop (RED) thresholds on a FIFO threshold
8638c2ecf20Sopenharmony_ci * basis. probability should increase when the FIFO level increases. control
8648c2ecf20Sopenharmony_ci * packets are never dropped and not counted in stats. probability programmed
8658c2ecf20Sopenharmony_ci * on a 12.5% granularity. e.g., 0x1 = 1/8 packets dropped.
8668c2ecf20Sopenharmony_ci * DEFAULT: 0x00000000
8678c2ecf20Sopenharmony_ci */
8688c2ecf20Sopenharmony_ci#define  REG_RX_RED                      0x404C  /* RX random early detect enable */
8698c2ecf20Sopenharmony_ci#define    RX_RED_4K_6K_FIFO_MASK        0x000000FF /*  4KB < FIFO thresh < 6KB */
8708c2ecf20Sopenharmony_ci#define    RX_RED_6K_8K_FIFO_MASK        0x0000FF00 /*  6KB < FIFO thresh < 8KB */
8718c2ecf20Sopenharmony_ci#define    RX_RED_8K_10K_FIFO_MASK       0x00FF0000 /*  8KB < FIFO thresh < 10KB */
8728c2ecf20Sopenharmony_ci#define    RX_RED_10K_12K_FIFO_MASK      0xFF000000 /* 10KB < FIFO thresh < 12KB */
8738c2ecf20Sopenharmony_ci
8748c2ecf20Sopenharmony_ci/* FIFO fullness levels for RX FIFO, RX control FIFO, and RX IPP FIFO.
8758c2ecf20Sopenharmony_ci * RX control FIFO = # of packets in RX FIFO.
8768c2ecf20Sopenharmony_ci * DEFAULT: 0x0
8778c2ecf20Sopenharmony_ci */
8788c2ecf20Sopenharmony_ci#define  REG_RX_FIFO_FULLNESS              0x4050  /* (ro) RX FIFO fullness */
8798c2ecf20Sopenharmony_ci#define    RX_FIFO_FULLNESS_RX_FIFO_MASK   0x3FF80000 /* level w/ 8B granularity */
8808c2ecf20Sopenharmony_ci#define    RX_FIFO_FULLNESS_IPP_FIFO_MASK  0x0007FF00 /* level w/ 8B granularity */
8818c2ecf20Sopenharmony_ci#define    RX_FIFO_FULLNESS_RX_PKT_MASK    0x000000FF /* # packets in RX FIFO */
8828c2ecf20Sopenharmony_ci#define  REG_RX_IPP_PACKET_COUNT           0x4054  /* RX IPP packet counter */
8838c2ecf20Sopenharmony_ci#define  REG_RX_WORK_DMA_PTR_LOW           0x4058  /* RX working DMA ptr low */
8848c2ecf20Sopenharmony_ci#define  REG_RX_WORK_DMA_PTR_HI            0x405C  /* RX working DMA ptr
8858c2ecf20Sopenharmony_ci						      high */
8868c2ecf20Sopenharmony_ci
8878c2ecf20Sopenharmony_ci/* BIST testing ro RX FIFO, RX control FIFO, and RX IPP FIFO. only RX BIST
8888c2ecf20Sopenharmony_ci * START/COMPLETE is writeable. START will clear when the BIST has completed
8898c2ecf20Sopenharmony_ci * checking all 17 RAMS.
8908c2ecf20Sopenharmony_ci * DEFAULT: 0bxxxx xxxxx xxxx xxxx xxxx x000 0000 0000 00x0
8918c2ecf20Sopenharmony_ci */
8928c2ecf20Sopenharmony_ci#define  REG_RX_BIST                       0x4060  /* (ro) RX BIST */
8938c2ecf20Sopenharmony_ci#define    RX_BIST_32A_PASS                0x80000000 /* RX FIFO 32A passed */
8948c2ecf20Sopenharmony_ci#define    RX_BIST_33A_PASS                0x40000000 /* RX FIFO 33A passed */
8958c2ecf20Sopenharmony_ci#define    RX_BIST_32B_PASS                0x20000000 /* RX FIFO 32B passed */
8968c2ecf20Sopenharmony_ci#define    RX_BIST_33B_PASS                0x10000000 /* RX FIFO 33B passed */
8978c2ecf20Sopenharmony_ci#define    RX_BIST_32C_PASS                0x08000000 /* RX FIFO 32C passed */
8988c2ecf20Sopenharmony_ci#define    RX_BIST_33C_PASS                0x04000000 /* RX FIFO 33C passed */
8998c2ecf20Sopenharmony_ci#define    RX_BIST_IPP_32A_PASS            0x02000000 /* RX IPP FIFO 33B passed */
9008c2ecf20Sopenharmony_ci#define    RX_BIST_IPP_33A_PASS            0x01000000 /* RX IPP FIFO 33A passed */
9018c2ecf20Sopenharmony_ci#define    RX_BIST_IPP_32B_PASS            0x00800000 /* RX IPP FIFO 32B passed */
9028c2ecf20Sopenharmony_ci#define    RX_BIST_IPP_33B_PASS            0x00400000 /* RX IPP FIFO 33B passed */
9038c2ecf20Sopenharmony_ci#define    RX_BIST_IPP_32C_PASS            0x00200000 /* RX IPP FIFO 32C passed */
9048c2ecf20Sopenharmony_ci#define    RX_BIST_IPP_33C_PASS            0x00100000 /* RX IPP FIFO 33C passed */
9058c2ecf20Sopenharmony_ci#define    RX_BIST_CTRL_32_PASS            0x00800000 /* RX CTRL FIFO 32 passed */
9068c2ecf20Sopenharmony_ci#define    RX_BIST_CTRL_33_PASS            0x00400000 /* RX CTRL FIFO 33 passed */
9078c2ecf20Sopenharmony_ci#define    RX_BIST_REAS_26A_PASS           0x00200000 /* RX Reas 26A passed */
9088c2ecf20Sopenharmony_ci#define    RX_BIST_REAS_26B_PASS           0x00100000 /* RX Reas 26B passed */
9098c2ecf20Sopenharmony_ci#define    RX_BIST_REAS_27_PASS            0x00080000 /* RX Reas 27 passed */
9108c2ecf20Sopenharmony_ci#define    RX_BIST_STATE_MASK              0x00078000 /* BIST state machine */
9118c2ecf20Sopenharmony_ci#define    RX_BIST_SUMMARY                 0x00000002 /* when BIST complete,
9128c2ecf20Sopenharmony_ci							 summary pass bit
9138c2ecf20Sopenharmony_ci							 contains AND of BIST
9148c2ecf20Sopenharmony_ci							 results of all 16
9158c2ecf20Sopenharmony_ci							 RAMS */
9168c2ecf20Sopenharmony_ci#define    RX_BIST_START                   0x00000001 /* write 1 to start
9178c2ecf20Sopenharmony_ci							 BIST. self clears
9188c2ecf20Sopenharmony_ci							 on completion. */
9198c2ecf20Sopenharmony_ci
9208c2ecf20Sopenharmony_ci/* next location in RX CTRL FIFO that will be loaded w/ data from RX IPP/read
9218c2ecf20Sopenharmony_ci * from to retrieve packet control info.
9228c2ecf20Sopenharmony_ci * DEFAULT: 0
9238c2ecf20Sopenharmony_ci */
9248c2ecf20Sopenharmony_ci#define  REG_RX_CTRL_FIFO_WRITE_PTR        0x4064  /* (ro) RX control FIFO
9258c2ecf20Sopenharmony_ci						      write ptr */
9268c2ecf20Sopenharmony_ci#define  REG_RX_CTRL_FIFO_READ_PTR         0x4068  /* (ro) RX control FIFO read
9278c2ecf20Sopenharmony_ci						      ptr */
9288c2ecf20Sopenharmony_ci
9298c2ecf20Sopenharmony_ci/* receive interrupt blanking. loaded each time interrupt alias register is
9308c2ecf20Sopenharmony_ci * read.
9318c2ecf20Sopenharmony_ci * DEFAULT: 0x0
9328c2ecf20Sopenharmony_ci */
9338c2ecf20Sopenharmony_ci#define  REG_RX_BLANK_ALIAS_READ           0x406C  /* RX blanking register for
9348c2ecf20Sopenharmony_ci						      alias read */
9358c2ecf20Sopenharmony_ci#define    RX_BAR_INTR_PACKET_MASK         0x000001FF /* assert RX_DONE if #
9368c2ecf20Sopenharmony_ci							 completion writebacks
9378c2ecf20Sopenharmony_ci							 > # since last ISR
9388c2ecf20Sopenharmony_ci							 read. 0 = no
9398c2ecf20Sopenharmony_ci							 blanking. up to 2
9408c2ecf20Sopenharmony_ci							 packets per
9418c2ecf20Sopenharmony_ci							 completion wb. */
9428c2ecf20Sopenharmony_ci#define    RX_BAR_INTR_TIME_MASK           0x3FFFF000 /* assert RX_DONE if #
9438c2ecf20Sopenharmony_ci							 clocks > # since last
9448c2ecf20Sopenharmony_ci							 ISR read. each count
9458c2ecf20Sopenharmony_ci							 is 512 core clocks
9468c2ecf20Sopenharmony_ci							 (125MHz). 0 = no
9478c2ecf20Sopenharmony_ci							 blanking. */
9488c2ecf20Sopenharmony_ci
9498c2ecf20Sopenharmony_ci/* diagnostic access to RX FIFO. 32 LSB accessed via DATA_LOW. 32 MSB accessed
9508c2ecf20Sopenharmony_ci * via DATA_HI_T0 or DATA_HI_T1. TAG reads the tag bit. writing HI_T0
9518c2ecf20Sopenharmony_ci * will unset the tag bit while writing HI_T1 will set the tag bit. to reset
9528c2ecf20Sopenharmony_ci * to normal operation after diagnostics, write to address location 0x0.
9538c2ecf20Sopenharmony_ci * RX_DMA_EN bit must be set to 0x0 for RX FIFO PIO access. DATA_HI should
9548c2ecf20Sopenharmony_ci * be the last write access of a write sequence.
9558c2ecf20Sopenharmony_ci * DEFAULT: undefined
9568c2ecf20Sopenharmony_ci */
9578c2ecf20Sopenharmony_ci#define  REG_RX_FIFO_ADDR                  0x4080  /* RX FIFO address */
9588c2ecf20Sopenharmony_ci#define  REG_RX_FIFO_TAG                   0x4084  /* RX FIFO tag */
9598c2ecf20Sopenharmony_ci#define  REG_RX_FIFO_DATA_LOW              0x4088  /* RX FIFO data low */
9608c2ecf20Sopenharmony_ci#define  REG_RX_FIFO_DATA_HI_T0            0x408C  /* RX FIFO data high T0 */
9618c2ecf20Sopenharmony_ci#define  REG_RX_FIFO_DATA_HI_T1            0x4090  /* RX FIFO data high T1 */
9628c2ecf20Sopenharmony_ci
9638c2ecf20Sopenharmony_ci/* diagnostic assess to RX CTRL FIFO. 8-bit FIFO_ADDR holds address of
9648c2ecf20Sopenharmony_ci * 81 bit control entry and 6 bit flow id. LOW and MID are both 32-bit
9658c2ecf20Sopenharmony_ci * accesses. HI is 7-bits with 6-bit flow id and 1 bit control
9668c2ecf20Sopenharmony_ci * word. RX_DMA_EN must be 0 for RX CTRL FIFO PIO access. DATA_HI
9678c2ecf20Sopenharmony_ci * should be last write access of the write sequence.
9688c2ecf20Sopenharmony_ci * DEFAULT: undefined
9698c2ecf20Sopenharmony_ci */
9708c2ecf20Sopenharmony_ci#define  REG_RX_CTRL_FIFO_ADDR             0x4094  /* RX Control FIFO and
9718c2ecf20Sopenharmony_ci						      Batching FIFO addr */
9728c2ecf20Sopenharmony_ci#define  REG_RX_CTRL_FIFO_DATA_LOW         0x4098  /* RX Control FIFO data
9738c2ecf20Sopenharmony_ci						      low */
9748c2ecf20Sopenharmony_ci#define  REG_RX_CTRL_FIFO_DATA_MID         0x409C  /* RX Control FIFO data
9758c2ecf20Sopenharmony_ci						      mid */
9768c2ecf20Sopenharmony_ci#define  REG_RX_CTRL_FIFO_DATA_HI          0x4100  /* RX Control FIFO data
9778c2ecf20Sopenharmony_ci						      hi and flow id */
9788c2ecf20Sopenharmony_ci#define    RX_CTRL_FIFO_DATA_HI_CTRL       0x0001  /* upper bit of ctrl word */
9798c2ecf20Sopenharmony_ci#define    RX_CTRL_FIFO_DATA_HI_FLOW_MASK  0x007E  /* flow id */
9808c2ecf20Sopenharmony_ci
9818c2ecf20Sopenharmony_ci/* diagnostic access to RX IPP FIFO. same semantics as RX_FIFO.
9828c2ecf20Sopenharmony_ci * DEFAULT: undefined
9838c2ecf20Sopenharmony_ci */
9848c2ecf20Sopenharmony_ci#define  REG_RX_IPP_FIFO_ADDR              0x4104  /* RX IPP FIFO address */
9858c2ecf20Sopenharmony_ci#define  REG_RX_IPP_FIFO_TAG               0x4108  /* RX IPP FIFO tag */
9868c2ecf20Sopenharmony_ci#define  REG_RX_IPP_FIFO_DATA_LOW          0x410C  /* RX IPP FIFO data low */
9878c2ecf20Sopenharmony_ci#define  REG_RX_IPP_FIFO_DATA_HI_T0        0x4110  /* RX IPP FIFO data high
9888c2ecf20Sopenharmony_ci						      T0 */
9898c2ecf20Sopenharmony_ci#define  REG_RX_IPP_FIFO_DATA_HI_T1        0x4114  /* RX IPP FIFO data high
9908c2ecf20Sopenharmony_ci						      T1 */
9918c2ecf20Sopenharmony_ci
9928c2ecf20Sopenharmony_ci/* 64-bit pointer to receive data buffer in host memory used for headers and
9938c2ecf20Sopenharmony_ci * small packets. MSB in high register. loaded by DMA state machine and
9948c2ecf20Sopenharmony_ci * increments as DMA writes receive data. only 50 LSB are incremented. top
9958c2ecf20Sopenharmony_ci * 13 bits taken from RX descriptor.
9968c2ecf20Sopenharmony_ci * DEFAULT: undefined
9978c2ecf20Sopenharmony_ci */
9988c2ecf20Sopenharmony_ci#define  REG_RX_HEADER_PAGE_PTR_LOW        0x4118  /* (ro) RX header page ptr
9998c2ecf20Sopenharmony_ci						      low */
10008c2ecf20Sopenharmony_ci#define  REG_RX_HEADER_PAGE_PTR_HI         0x411C  /* (ro) RX header page ptr
10018c2ecf20Sopenharmony_ci						      high */
10028c2ecf20Sopenharmony_ci#define  REG_RX_MTU_PAGE_PTR_LOW           0x4120  /* (ro) RX MTU page pointer
10038c2ecf20Sopenharmony_ci						      low */
10048c2ecf20Sopenharmony_ci#define  REG_RX_MTU_PAGE_PTR_HI            0x4124  /* (ro) RX MTU page pointer
10058c2ecf20Sopenharmony_ci						      high */
10068c2ecf20Sopenharmony_ci
10078c2ecf20Sopenharmony_ci/* PIO diagnostic access to RX reassembly DMA Table RAM. 6-bit register holds
10088c2ecf20Sopenharmony_ci * one of 64 79-bit locations in the RX Reassembly DMA table and the addr of
10098c2ecf20Sopenharmony_ci * one of the 64 byte locations in the Batching table. LOW holds 32 LSB.
10108c2ecf20Sopenharmony_ci * MID holds the next 32 LSB. HIGH holds the 15 MSB. RX_DMA_EN must be set
10118c2ecf20Sopenharmony_ci * to 0 for PIO access. DATA_HIGH should be last write of write sequence.
10128c2ecf20Sopenharmony_ci * layout:
10138c2ecf20Sopenharmony_ci * reassmbl ptr [78:15] | reassmbl index [14:1] | reassmbl entry valid [0]
10148c2ecf20Sopenharmony_ci * DEFAULT: undefined
10158c2ecf20Sopenharmony_ci */
10168c2ecf20Sopenharmony_ci#define  REG_RX_TABLE_ADDR             0x4128  /* RX reassembly DMA table
10178c2ecf20Sopenharmony_ci						  address */
10188c2ecf20Sopenharmony_ci#define    RX_TABLE_ADDR_MASK          0x0000003F /* address mask */
10198c2ecf20Sopenharmony_ci
10208c2ecf20Sopenharmony_ci#define  REG_RX_TABLE_DATA_LOW         0x412C  /* RX reassembly DMA table
10218c2ecf20Sopenharmony_ci						  data low */
10228c2ecf20Sopenharmony_ci#define  REG_RX_TABLE_DATA_MID         0x4130  /* RX reassembly DMA table
10238c2ecf20Sopenharmony_ci						  data mid */
10248c2ecf20Sopenharmony_ci#define  REG_RX_TABLE_DATA_HI          0x4134  /* RX reassembly DMA table
10258c2ecf20Sopenharmony_ci						  data high */
10268c2ecf20Sopenharmony_ci
10278c2ecf20Sopenharmony_ci/* cassini+ only */
10288c2ecf20Sopenharmony_ci/* 8KB aligned 64-bit pointer to base of RX rings. lower 13 bits hardwired to
10298c2ecf20Sopenharmony_ci * 0. same semantics as primary desc/complete rings.
10308c2ecf20Sopenharmony_ci */
10318c2ecf20Sopenharmony_ci#define  REG_PLUS_RX_DB1_LOW            0x4200  /* RX descriptor ring
10328c2ecf20Sopenharmony_ci						   2 base low */
10338c2ecf20Sopenharmony_ci#define  REG_PLUS_RX_DB1_HI             0x4204  /* RX descriptor ring
10348c2ecf20Sopenharmony_ci						   2 base high */
10358c2ecf20Sopenharmony_ci#define  REG_PLUS_RX_CB1_LOW            0x4208  /* RX completion ring
10368c2ecf20Sopenharmony_ci						   2 base low. 4 total */
10378c2ecf20Sopenharmony_ci#define  REG_PLUS_RX_CB1_HI             0x420C  /* RX completion ring
10388c2ecf20Sopenharmony_ci						   2 base high. 4 total */
10398c2ecf20Sopenharmony_ci#define  REG_PLUS_RX_CBN_LOW(x)        (REG_PLUS_RX_CB1_LOW + 8*((x) - 1))
10408c2ecf20Sopenharmony_ci#define  REG_PLUS_RX_CBN_HI(x)         (REG_PLUS_RX_CB1_HI + 8*((x) - 1))
10418c2ecf20Sopenharmony_ci#define  REG_PLUS_RX_KICK1             0x4220  /* RX Kick 2 register */
10428c2ecf20Sopenharmony_ci#define  REG_PLUS_RX_COMP1             0x4224  /* (ro) RX completion 2
10438c2ecf20Sopenharmony_ci						  reg */
10448c2ecf20Sopenharmony_ci#define  REG_PLUS_RX_COMP1_HEAD        0x4228  /* (ro) RX completion 2
10458c2ecf20Sopenharmony_ci						  head reg. 4 total. */
10468c2ecf20Sopenharmony_ci#define  REG_PLUS_RX_COMP1_TAIL        0x422C  /* RX completion 2
10478c2ecf20Sopenharmony_ci						  tail reg. 4 total. */
10488c2ecf20Sopenharmony_ci#define  REG_PLUS_RX_COMPN_HEAD(x)    (REG_PLUS_RX_COMP1_HEAD + 8*((x) - 1))
10498c2ecf20Sopenharmony_ci#define  REG_PLUS_RX_COMPN_TAIL(x)    (REG_PLUS_RX_COMP1_TAIL + 8*((x) - 1))
10508c2ecf20Sopenharmony_ci#define  REG_PLUS_RX_AE1_THRESH        0x4240  /* RX almost empty 2
10518c2ecf20Sopenharmony_ci						  thresholds */
10528c2ecf20Sopenharmony_ci#define    RX_AE1_THRESH_FREE_MASK     RX_AE_THRESH_FREE_MASK
10538c2ecf20Sopenharmony_ci#define    RX_AE1_THRESH_FREE_SHIFT    RX_AE_THRESH_FREE_SHIFT
10548c2ecf20Sopenharmony_ci
10558c2ecf20Sopenharmony_ci/** header parser registers **/
10568c2ecf20Sopenharmony_ci
10578c2ecf20Sopenharmony_ci/* RX parser configuration register.
10588c2ecf20Sopenharmony_ci * DEFAULT: 0x1651004
10598c2ecf20Sopenharmony_ci */
10608c2ecf20Sopenharmony_ci#define  REG_HP_CFG                       0x4140  /* header parser
10618c2ecf20Sopenharmony_ci						     configuration reg */
10628c2ecf20Sopenharmony_ci#define    HP_CFG_PARSE_EN                0x00000001 /* enab header parsing */
10638c2ecf20Sopenharmony_ci#define    HP_CFG_NUM_CPU_MASK            0x000000FC /* # processors
10648c2ecf20Sopenharmony_ci						      0 = 64. 0x3f = 63 */
10658c2ecf20Sopenharmony_ci#define    HP_CFG_NUM_CPU_SHIFT           2
10668c2ecf20Sopenharmony_ci#define    HP_CFG_SYN_INC_MASK            0x00000100 /* SYN bit won't increment
10678c2ecf20Sopenharmony_ci							TCP seq # by one when
10688c2ecf20Sopenharmony_ci							stored in FDBM */
10698c2ecf20Sopenharmony_ci#define    HP_CFG_TCP_THRESH_MASK         0x000FFE00 /* # bytes of TCP data
10708c2ecf20Sopenharmony_ci							needed to be considered
10718c2ecf20Sopenharmony_ci							for reassembly */
10728c2ecf20Sopenharmony_ci#define    HP_CFG_TCP_THRESH_SHIFT        9
10738c2ecf20Sopenharmony_ci
10748c2ecf20Sopenharmony_ci/* access to RX Instruction RAM. 5-bit register/counter holds addr
10758c2ecf20Sopenharmony_ci * of 39 bit entry to be read/written. 32 LSB in _DATA_LOW. 7 MSB in _DATA_HI.
10768c2ecf20Sopenharmony_ci * RX_DMA_EN must be 0 for RX instr PIO access. DATA_HI should be last access
10778c2ecf20Sopenharmony_ci * of sequence.
10788c2ecf20Sopenharmony_ci * DEFAULT: undefined
10798c2ecf20Sopenharmony_ci */
10808c2ecf20Sopenharmony_ci#define  REG_HP_INSTR_RAM_ADDR             0x4144  /* HP instruction RAM
10818c2ecf20Sopenharmony_ci						      address */
10828c2ecf20Sopenharmony_ci#define    HP_INSTR_RAM_ADDR_MASK          0x01F   /* 5-bit mask */
10838c2ecf20Sopenharmony_ci#define  REG_HP_INSTR_RAM_DATA_LOW         0x4148  /* HP instruction RAM
10848c2ecf20Sopenharmony_ci						      data low */
10858c2ecf20Sopenharmony_ci#define    HP_INSTR_RAM_LOW_OUTMASK_MASK   0x0000FFFF
10868c2ecf20Sopenharmony_ci#define    HP_INSTR_RAM_LOW_OUTMASK_SHIFT  0
10878c2ecf20Sopenharmony_ci#define    HP_INSTR_RAM_LOW_OUTSHIFT_MASK  0x000F0000
10888c2ecf20Sopenharmony_ci#define    HP_INSTR_RAM_LOW_OUTSHIFT_SHIFT 16
10898c2ecf20Sopenharmony_ci#define    HP_INSTR_RAM_LOW_OUTEN_MASK     0x00300000
10908c2ecf20Sopenharmony_ci#define    HP_INSTR_RAM_LOW_OUTEN_SHIFT    20
10918c2ecf20Sopenharmony_ci#define    HP_INSTR_RAM_LOW_OUTARG_MASK    0xFFC00000
10928c2ecf20Sopenharmony_ci#define    HP_INSTR_RAM_LOW_OUTARG_SHIFT   22
10938c2ecf20Sopenharmony_ci#define  REG_HP_INSTR_RAM_DATA_MID         0x414C  /* HP instruction RAM
10948c2ecf20Sopenharmony_ci						      data mid */
10958c2ecf20Sopenharmony_ci#define    HP_INSTR_RAM_MID_OUTARG_MASK    0x00000003
10968c2ecf20Sopenharmony_ci#define    HP_INSTR_RAM_MID_OUTARG_SHIFT   0
10978c2ecf20Sopenharmony_ci#define    HP_INSTR_RAM_MID_OUTOP_MASK     0x0000003C
10988c2ecf20Sopenharmony_ci#define    HP_INSTR_RAM_MID_OUTOP_SHIFT    2
10998c2ecf20Sopenharmony_ci#define    HP_INSTR_RAM_MID_FNEXT_MASK     0x000007C0
11008c2ecf20Sopenharmony_ci#define    HP_INSTR_RAM_MID_FNEXT_SHIFT    6
11018c2ecf20Sopenharmony_ci#define    HP_INSTR_RAM_MID_FOFF_MASK      0x0003F800
11028c2ecf20Sopenharmony_ci#define    HP_INSTR_RAM_MID_FOFF_SHIFT     11
11038c2ecf20Sopenharmony_ci#define    HP_INSTR_RAM_MID_SNEXT_MASK     0x007C0000
11048c2ecf20Sopenharmony_ci#define    HP_INSTR_RAM_MID_SNEXT_SHIFT    18
11058c2ecf20Sopenharmony_ci#define    HP_INSTR_RAM_MID_SOFF_MASK      0x3F800000
11068c2ecf20Sopenharmony_ci#define    HP_INSTR_RAM_MID_SOFF_SHIFT     23
11078c2ecf20Sopenharmony_ci#define    HP_INSTR_RAM_MID_OP_MASK        0xC0000000
11088c2ecf20Sopenharmony_ci#define    HP_INSTR_RAM_MID_OP_SHIFT       30
11098c2ecf20Sopenharmony_ci#define  REG_HP_INSTR_RAM_DATA_HI          0x4150  /* HP instruction RAM
11108c2ecf20Sopenharmony_ci						      data high */
11118c2ecf20Sopenharmony_ci#define    HP_INSTR_RAM_HI_VAL_MASK        0x0000FFFF
11128c2ecf20Sopenharmony_ci#define    HP_INSTR_RAM_HI_VAL_SHIFT       0
11138c2ecf20Sopenharmony_ci#define    HP_INSTR_RAM_HI_MASK_MASK       0xFFFF0000
11148c2ecf20Sopenharmony_ci#define    HP_INSTR_RAM_HI_MASK_SHIFT      16
11158c2ecf20Sopenharmony_ci
11168c2ecf20Sopenharmony_ci/* PIO access into RX Header parser data RAM and flow database.
11178c2ecf20Sopenharmony_ci * 11-bit register. Data fills the LSB portion of bus if less than 32 bits.
11188c2ecf20Sopenharmony_ci * DATA_RAM: write RAM_FDB_DATA with index to access DATA_RAM.
11198c2ecf20Sopenharmony_ci * RAM bytes = 4*(x - 1) + [3:0]. e.g., 0 -> [3:0], 31 -> [123:120]
11208c2ecf20Sopenharmony_ci * FLOWDB: write DATA_RAM_FDB register and then read/write FDB1-12 to access
11218c2ecf20Sopenharmony_ci * flow database.
11228c2ecf20Sopenharmony_ci * RX_DMA_EN must be 0 for RX parser RAM PIO access. RX Parser RAM data reg
11238c2ecf20Sopenharmony_ci * should be the last write access of the write sequence.
11248c2ecf20Sopenharmony_ci * DEFAULT: undefined
11258c2ecf20Sopenharmony_ci */
11268c2ecf20Sopenharmony_ci#define  REG_HP_DATA_RAM_FDB_ADDR          0x4154  /* HP data and FDB
11278c2ecf20Sopenharmony_ci						      RAM address */
11288c2ecf20Sopenharmony_ci#define    HP_DATA_RAM_FDB_DATA_MASK       0x001F  /* select 1 of 86 byte
11298c2ecf20Sopenharmony_ci						      locations in header
11308c2ecf20Sopenharmony_ci						      parser data ram to
11318c2ecf20Sopenharmony_ci						      read/write */
11328c2ecf20Sopenharmony_ci#define    HP_DATA_RAM_FDB_FDB_MASK        0x3F00  /* 1 of 64 353-bit locations
11338c2ecf20Sopenharmony_ci						      in the flow database */
11348c2ecf20Sopenharmony_ci#define  REG_HP_DATA_RAM_DATA              0x4158  /* HP data RAM data */
11358c2ecf20Sopenharmony_ci
11368c2ecf20Sopenharmony_ci/* HP flow database registers: 1 - 12, 0x415C - 0x4188, 4 8-bit bytes
11378c2ecf20Sopenharmony_ci * FLOW_DB(1) = IP_SA[127:96], FLOW_DB(2) = IP_SA[95:64]
11388c2ecf20Sopenharmony_ci * FLOW_DB(3) = IP_SA[63:32],  FLOW_DB(4) = IP_SA[31:0]
11398c2ecf20Sopenharmony_ci * FLOW_DB(5) = IP_DA[127:96], FLOW_DB(6) = IP_DA[95:64]
11408c2ecf20Sopenharmony_ci * FLOW_DB(7) = IP_DA[63:32],  FLOW_DB(8) = IP_DA[31:0]
11418c2ecf20Sopenharmony_ci * FLOW_DB(9) = {TCP_SP[15:0],TCP_DP[15:0]}
11428c2ecf20Sopenharmony_ci * FLOW_DB(10) = bit 0 has value for flow valid
11438c2ecf20Sopenharmony_ci * FLOW_DB(11) = TCP_SEQ[63:32], FLOW_DB(12) = TCP_SEQ[31:0]
11448c2ecf20Sopenharmony_ci */
11458c2ecf20Sopenharmony_ci#define  REG_HP_FLOW_DB0                   0x415C  /* HP flow database 1 reg */
11468c2ecf20Sopenharmony_ci#define  REG_HP_FLOW_DBN(x)                (REG_HP_FLOW_DB0 + (x)*4)
11478c2ecf20Sopenharmony_ci
11488c2ecf20Sopenharmony_ci/* diagnostics for RX Header Parser block.
11498c2ecf20Sopenharmony_ci * ASUN: the header parser state machine register is used for diagnostics
11508c2ecf20Sopenharmony_ci * purposes. however, the spec doesn't have any details on it.
11518c2ecf20Sopenharmony_ci */
11528c2ecf20Sopenharmony_ci#define  REG_HP_STATE_MACHINE              0x418C  /* (ro) HP state machine */
11538c2ecf20Sopenharmony_ci#define  REG_HP_STATUS0                    0x4190  /* (ro) HP status 1 */
11548c2ecf20Sopenharmony_ci#define    HP_STATUS0_SAP_MASK             0xFFFF0000 /* SAP */
11558c2ecf20Sopenharmony_ci#define    HP_STATUS0_L3_OFF_MASK          0x0000FE00 /* L3 offset */
11568c2ecf20Sopenharmony_ci#define    HP_STATUS0_LB_CPUNUM_MASK       0x000001F8 /* load balancing CPU
11578c2ecf20Sopenharmony_ci							 number */
11588c2ecf20Sopenharmony_ci#define    HP_STATUS0_HRP_OPCODE_MASK      0x00000007 /* HRP opcode */
11598c2ecf20Sopenharmony_ci
11608c2ecf20Sopenharmony_ci#define  REG_HP_STATUS1                    0x4194  /* (ro) HP status 2 */
11618c2ecf20Sopenharmony_ci#define    HP_STATUS1_ACCUR2_MASK          0xE0000000 /* accu R2[6:4] */
11628c2ecf20Sopenharmony_ci#define    HP_STATUS1_FLOWID_MASK          0x1F800000 /* flow id */
11638c2ecf20Sopenharmony_ci#define    HP_STATUS1_TCP_OFF_MASK         0x007F0000 /* tcp payload offset */
11648c2ecf20Sopenharmony_ci#define    HP_STATUS1_TCP_SIZE_MASK        0x0000FFFF /* tcp payload size */
11658c2ecf20Sopenharmony_ci
11668c2ecf20Sopenharmony_ci#define  REG_HP_STATUS2                    0x4198  /* (ro) HP status 3 */
11678c2ecf20Sopenharmony_ci#define    HP_STATUS2_ACCUR2_MASK          0xF0000000 /* accu R2[3:0] */
11688c2ecf20Sopenharmony_ci#define    HP_STATUS2_CSUM_OFF_MASK        0x07F00000 /* checksum start
11698c2ecf20Sopenharmony_ci							 start offset */
11708c2ecf20Sopenharmony_ci#define    HP_STATUS2_ACCUR1_MASK          0x000FE000 /* accu R1 */
11718c2ecf20Sopenharmony_ci#define    HP_STATUS2_FORCE_DROP           0x00001000 /* force drop */
11728c2ecf20Sopenharmony_ci#define    HP_STATUS2_BWO_REASSM           0x00000800 /* batching w/o
11738c2ecf20Sopenharmony_ci							 reassembly */
11748c2ecf20Sopenharmony_ci#define    HP_STATUS2_JH_SPLIT_EN          0x00000400 /* jumbo header split
11758c2ecf20Sopenharmony_ci							 enable */
11768c2ecf20Sopenharmony_ci#define    HP_STATUS2_FORCE_TCP_NOCHECK    0x00000200 /* force tcp no payload
11778c2ecf20Sopenharmony_ci							 check */
11788c2ecf20Sopenharmony_ci#define    HP_STATUS2_DATA_MASK_ZERO       0x00000100 /* mask of data length
11798c2ecf20Sopenharmony_ci							 equal to zero */
11808c2ecf20Sopenharmony_ci#define    HP_STATUS2_FORCE_TCP_CHECK      0x00000080 /* force tcp payload
11818c2ecf20Sopenharmony_ci							 chk */
11828c2ecf20Sopenharmony_ci#define    HP_STATUS2_MASK_TCP_THRESH      0x00000040 /* mask of payload
11838c2ecf20Sopenharmony_ci							 threshold */
11848c2ecf20Sopenharmony_ci#define    HP_STATUS2_NO_ASSIST            0x00000020 /* no assist */
11858c2ecf20Sopenharmony_ci#define    HP_STATUS2_CTRL_PACKET_FLAG     0x00000010 /* control packet flag */
11868c2ecf20Sopenharmony_ci#define    HP_STATUS2_TCP_FLAG_CHECK       0x00000008 /* tcp flag check */
11878c2ecf20Sopenharmony_ci#define    HP_STATUS2_SYN_FLAG             0x00000004 /* syn flag */
11888c2ecf20Sopenharmony_ci#define    HP_STATUS2_TCP_CHECK            0x00000002 /* tcp payload chk */
11898c2ecf20Sopenharmony_ci#define    HP_STATUS2_TCP_NOCHECK          0x00000001 /* tcp no payload chk */
11908c2ecf20Sopenharmony_ci
11918c2ecf20Sopenharmony_ci/* BIST for header parser(HP) and flow database memories (FDBM). set _START
11928c2ecf20Sopenharmony_ci * to start BIST. controller clears _START on completion. _START can also
11938c2ecf20Sopenharmony_ci * be cleared to force termination of BIST. a bit set indicates that that
11948c2ecf20Sopenharmony_ci * memory passed its BIST.
11958c2ecf20Sopenharmony_ci */
11968c2ecf20Sopenharmony_ci#define  REG_HP_RAM_BIST                   0x419C  /* HP RAM BIST reg */
11978c2ecf20Sopenharmony_ci#define    HP_RAM_BIST_HP_DATA_PASS        0x80000000 /* HP data ram */
11988c2ecf20Sopenharmony_ci#define    HP_RAM_BIST_HP_INSTR0_PASS      0x40000000 /* HP instr ram 0 */
11998c2ecf20Sopenharmony_ci#define    HP_RAM_BIST_HP_INSTR1_PASS      0x20000000 /* HP instr ram 1 */
12008c2ecf20Sopenharmony_ci#define    HP_RAM_BIST_HP_INSTR2_PASS      0x10000000 /* HP instr ram 2 */
12018c2ecf20Sopenharmony_ci#define    HP_RAM_BIST_FDBM_AGE0_PASS      0x08000000 /* FDBM aging RAM0 */
12028c2ecf20Sopenharmony_ci#define    HP_RAM_BIST_FDBM_AGE1_PASS      0x04000000 /* FDBM aging RAM1 */
12038c2ecf20Sopenharmony_ci#define    HP_RAM_BIST_FDBM_FLOWID00_PASS  0x02000000 /* FDBM flowid RAM0
12048c2ecf20Sopenharmony_ci							 bank 0 */
12058c2ecf20Sopenharmony_ci#define    HP_RAM_BIST_FDBM_FLOWID10_PASS  0x01000000 /* FDBM flowid RAM1
12068c2ecf20Sopenharmony_ci							 bank 0 */
12078c2ecf20Sopenharmony_ci#define    HP_RAM_BIST_FDBM_FLOWID20_PASS  0x00800000 /* FDBM flowid RAM2
12088c2ecf20Sopenharmony_ci							 bank 0 */
12098c2ecf20Sopenharmony_ci#define    HP_RAM_BIST_FDBM_FLOWID30_PASS  0x00400000 /* FDBM flowid RAM3
12108c2ecf20Sopenharmony_ci							 bank 0 */
12118c2ecf20Sopenharmony_ci#define    HP_RAM_BIST_FDBM_FLOWID01_PASS  0x00200000 /* FDBM flowid RAM0
12128c2ecf20Sopenharmony_ci							 bank 1 */
12138c2ecf20Sopenharmony_ci#define    HP_RAM_BIST_FDBM_FLOWID11_PASS  0x00100000 /* FDBM flowid RAM1
12148c2ecf20Sopenharmony_ci							 bank 2 */
12158c2ecf20Sopenharmony_ci#define    HP_RAM_BIST_FDBM_FLOWID21_PASS  0x00080000 /* FDBM flowid RAM2
12168c2ecf20Sopenharmony_ci							 bank 1 */
12178c2ecf20Sopenharmony_ci#define    HP_RAM_BIST_FDBM_FLOWID31_PASS  0x00040000 /* FDBM flowid RAM3
12188c2ecf20Sopenharmony_ci							 bank 1 */
12198c2ecf20Sopenharmony_ci#define    HP_RAM_BIST_FDBM_TCPSEQ_PASS    0x00020000 /* FDBM tcp sequence
12208c2ecf20Sopenharmony_ci							 RAM */
12218c2ecf20Sopenharmony_ci#define    HP_RAM_BIST_SUMMARY             0x00000002 /* all BIST tests */
12228c2ecf20Sopenharmony_ci#define    HP_RAM_BIST_START               0x00000001 /* start/stop BIST */
12238c2ecf20Sopenharmony_ci
12248c2ecf20Sopenharmony_ci
12258c2ecf20Sopenharmony_ci/** MAC registers.  **/
12268c2ecf20Sopenharmony_ci/* reset bits are set using a PIO write and self-cleared after the command
12278c2ecf20Sopenharmony_ci * execution has completed.
12288c2ecf20Sopenharmony_ci */
12298c2ecf20Sopenharmony_ci#define  REG_MAC_TX_RESET                  0x6000  /* TX MAC software reset
12308c2ecf20Sopenharmony_ci						      command (default: 0x0) */
12318c2ecf20Sopenharmony_ci#define  REG_MAC_RX_RESET                  0x6004  /* RX MAC software reset
12328c2ecf20Sopenharmony_ci						      command (default: 0x0) */
12338c2ecf20Sopenharmony_ci/* execute a pause flow control frame transmission
12348c2ecf20Sopenharmony_ci DEFAULT: 0x0XXXX */
12358c2ecf20Sopenharmony_ci#define  REG_MAC_SEND_PAUSE                0x6008  /* send pause command reg */
12368c2ecf20Sopenharmony_ci#define    MAC_SEND_PAUSE_TIME_MASK        0x0000FFFF /* value of pause time
12378c2ecf20Sopenharmony_ci							 to be sent on network
12388c2ecf20Sopenharmony_ci							 in units of slot
12398c2ecf20Sopenharmony_ci							 times */
12408c2ecf20Sopenharmony_ci#define    MAC_SEND_PAUSE_SEND             0x00010000 /* send pause flow ctrl
12418c2ecf20Sopenharmony_ci							 frame on network */
12428c2ecf20Sopenharmony_ci
12438c2ecf20Sopenharmony_ci/* bit set indicates that event occurred. auto-cleared when status register
12448c2ecf20Sopenharmony_ci * is read and have corresponding mask bits in mask register. events will
12458c2ecf20Sopenharmony_ci * trigger an interrupt if the corresponding mask bit is 0.
12468c2ecf20Sopenharmony_ci * status register default: 0x00000000
12478c2ecf20Sopenharmony_ci * mask register default = 0xFFFFFFFF on reset
12488c2ecf20Sopenharmony_ci */
12498c2ecf20Sopenharmony_ci#define  REG_MAC_TX_STATUS                 0x6010  /* TX MAC status reg */
12508c2ecf20Sopenharmony_ci#define    MAC_TX_FRAME_XMIT               0x0001  /* successful frame
12518c2ecf20Sopenharmony_ci						      transmision */
12528c2ecf20Sopenharmony_ci#define    MAC_TX_UNDERRUN                 0x0002  /* terminated frame
12538c2ecf20Sopenharmony_ci						      transmission due to
12548c2ecf20Sopenharmony_ci						      data starvation in the
12558c2ecf20Sopenharmony_ci						      xmit data path */
12568c2ecf20Sopenharmony_ci#define    MAC_TX_MAX_PACKET_ERR           0x0004  /* frame exceeds max allowed
12578c2ecf20Sopenharmony_ci						      length passed to TX MAC
12588c2ecf20Sopenharmony_ci						      by the DMA engine */
12598c2ecf20Sopenharmony_ci#define    MAC_TX_COLL_NORMAL              0x0008  /* rollover of the normal
12608c2ecf20Sopenharmony_ci						      collision counter */
12618c2ecf20Sopenharmony_ci#define    MAC_TX_COLL_EXCESS              0x0010  /* rollover of the excessive
12628c2ecf20Sopenharmony_ci						      collision counter */
12638c2ecf20Sopenharmony_ci#define    MAC_TX_COLL_LATE                0x0020  /* rollover of the late
12648c2ecf20Sopenharmony_ci						      collision counter */
12658c2ecf20Sopenharmony_ci#define    MAC_TX_COLL_FIRST               0x0040  /* rollover of the first
12668c2ecf20Sopenharmony_ci						      collision counter */
12678c2ecf20Sopenharmony_ci#define    MAC_TX_DEFER_TIMER              0x0080  /* rollover of the defer
12688c2ecf20Sopenharmony_ci						      timer */
12698c2ecf20Sopenharmony_ci#define    MAC_TX_PEAK_ATTEMPTS            0x0100  /* rollover of the peak
12708c2ecf20Sopenharmony_ci						      attempts counter */
12718c2ecf20Sopenharmony_ci
12728c2ecf20Sopenharmony_ci#define  REG_MAC_RX_STATUS                 0x6014  /* RX MAC status reg */
12738c2ecf20Sopenharmony_ci#define    MAC_RX_FRAME_RECV               0x0001  /* successful receipt of
12748c2ecf20Sopenharmony_ci						      a frame */
12758c2ecf20Sopenharmony_ci#define    MAC_RX_OVERFLOW                 0x0002  /* dropped frame due to
12768c2ecf20Sopenharmony_ci						      RX FIFO overflow */
12778c2ecf20Sopenharmony_ci#define    MAC_RX_FRAME_COUNT              0x0004  /* rollover of receive frame
12788c2ecf20Sopenharmony_ci						      counter */
12798c2ecf20Sopenharmony_ci#define    MAC_RX_ALIGN_ERR                0x0008  /* rollover of alignment
12808c2ecf20Sopenharmony_ci						      error counter */
12818c2ecf20Sopenharmony_ci#define    MAC_RX_CRC_ERR                  0x0010  /* rollover of crc error
12828c2ecf20Sopenharmony_ci						      counter */
12838c2ecf20Sopenharmony_ci#define    MAC_RX_LEN_ERR                  0x0020  /* rollover of length
12848c2ecf20Sopenharmony_ci						      error counter */
12858c2ecf20Sopenharmony_ci#define    MAC_RX_VIOL_ERR                 0x0040  /* rollover of code
12868c2ecf20Sopenharmony_ci						      violation error */
12878c2ecf20Sopenharmony_ci
12888c2ecf20Sopenharmony_ci/* DEFAULT: 0xXXXX0000 on reset */
12898c2ecf20Sopenharmony_ci#define  REG_MAC_CTRL_STATUS               0x6018  /* MAC control status reg */
12908c2ecf20Sopenharmony_ci#define    MAC_CTRL_PAUSE_RECEIVED         0x00000001  /* successful
12918c2ecf20Sopenharmony_ci							  reception of a
12928c2ecf20Sopenharmony_ci							  pause control
12938c2ecf20Sopenharmony_ci							  frame */
12948c2ecf20Sopenharmony_ci#define    MAC_CTRL_PAUSE_STATE            0x00000002  /* MAC has made a
12958c2ecf20Sopenharmony_ci							  transition from
12968c2ecf20Sopenharmony_ci							  "not paused" to
12978c2ecf20Sopenharmony_ci							  "paused" */
12988c2ecf20Sopenharmony_ci#define    MAC_CTRL_NOPAUSE_STATE          0x00000004  /* MAC has made a
12998c2ecf20Sopenharmony_ci							  transition from
13008c2ecf20Sopenharmony_ci							  "paused" to "not
13018c2ecf20Sopenharmony_ci							  paused" */
13028c2ecf20Sopenharmony_ci#define    MAC_CTRL_PAUSE_TIME_MASK        0xFFFF0000  /* value of pause time
13038c2ecf20Sopenharmony_ci							  operand that was
13048c2ecf20Sopenharmony_ci							  received in the last
13058c2ecf20Sopenharmony_ci							  pause flow control
13068c2ecf20Sopenharmony_ci							  frame */
13078c2ecf20Sopenharmony_ci
13088c2ecf20Sopenharmony_ci/* layout identical to TX MAC[8:0] */
13098c2ecf20Sopenharmony_ci#define  REG_MAC_TX_MASK                   0x6020  /* TX MAC mask reg */
13108c2ecf20Sopenharmony_ci/* layout identical to RX MAC[6:0] */
13118c2ecf20Sopenharmony_ci#define  REG_MAC_RX_MASK                   0x6024  /* RX MAC mask reg */
13128c2ecf20Sopenharmony_ci/* layout identical to CTRL MAC[2:0] */
13138c2ecf20Sopenharmony_ci#define  REG_MAC_CTRL_MASK                 0x6028  /* MAC control mask reg */
13148c2ecf20Sopenharmony_ci
13158c2ecf20Sopenharmony_ci/* to ensure proper operation, CFG_EN must be cleared to 0 and a delay
13168c2ecf20Sopenharmony_ci * imposed before writes to other bits in the TX_MAC_CFG register or any of
13178c2ecf20Sopenharmony_ci * the MAC parameters is performed. delay dependent upon time required to
13188c2ecf20Sopenharmony_ci * transmit a maximum size frame (= MAC_FRAMESIZE_MAX*8/Mbps). e.g.,
13198c2ecf20Sopenharmony_ci * the delay for a 1518-byte frame on a 100Mbps network is 125us.
13208c2ecf20Sopenharmony_ci * alternatively, just poll TX_CFG_EN until it reads back as 0.
13218c2ecf20Sopenharmony_ci * NOTE: on half-duplex 1Gbps, TX_CFG_CARRIER_EXTEND and
13228c2ecf20Sopenharmony_ci * RX_CFG_CARRIER_EXTEND should be set and the SLOT_TIME register should
13238c2ecf20Sopenharmony_ci * be 0x200 (slot time of 512 bytes)
13248c2ecf20Sopenharmony_ci */
13258c2ecf20Sopenharmony_ci#define  REG_MAC_TX_CFG                 0x6030  /* TX MAC config reg */
13268c2ecf20Sopenharmony_ci#define    MAC_TX_CFG_EN                0x0001  /* enable TX MAC. 0 will
13278c2ecf20Sopenharmony_ci						      force TXMAC state
13288c2ecf20Sopenharmony_ci						      machine to remain in
13298c2ecf20Sopenharmony_ci						      idle state or to
13308c2ecf20Sopenharmony_ci						      transition to idle state
13318c2ecf20Sopenharmony_ci						      on completion of an
13328c2ecf20Sopenharmony_ci						      ongoing packet. */
13338c2ecf20Sopenharmony_ci#define    MAC_TX_CFG_IGNORE_CARRIER    0x0002  /* disable CSMA/CD deferral
13348c2ecf20Sopenharmony_ci						   process. set to 1 when
13358c2ecf20Sopenharmony_ci						   full duplex and 0 when
13368c2ecf20Sopenharmony_ci						   half duplex */
13378c2ecf20Sopenharmony_ci#define    MAC_TX_CFG_IGNORE_COLL       0x0004  /* disable CSMA/CD backoff
13388c2ecf20Sopenharmony_ci						   algorithm. set to 1 when
13398c2ecf20Sopenharmony_ci						   full duplex and 0 when
13408c2ecf20Sopenharmony_ci						   half duplex */
13418c2ecf20Sopenharmony_ci#define    MAC_TX_CFG_IPG_EN            0x0008  /* enable extension of the
13428c2ecf20Sopenharmony_ci						   Rx-to-TX IPG. after
13438c2ecf20Sopenharmony_ci						   receiving a frame, TX
13448c2ecf20Sopenharmony_ci						   MAC will reset its
13458c2ecf20Sopenharmony_ci						   deferral process to
13468c2ecf20Sopenharmony_ci						   carrier sense for the
13478c2ecf20Sopenharmony_ci						   amount of time = IPG0 +
13488c2ecf20Sopenharmony_ci						   IPG1 and commit to
13498c2ecf20Sopenharmony_ci						   transmission for time
13508c2ecf20Sopenharmony_ci						   specified in IPG2. when
13518c2ecf20Sopenharmony_ci						   0 or when xmitting frames
13528c2ecf20Sopenharmony_ci						   back-to-pack (Tx-to-Tx
13538c2ecf20Sopenharmony_ci						   IPG), TX MAC ignores
13548c2ecf20Sopenharmony_ci						   IPG0 and will only use
13558c2ecf20Sopenharmony_ci						   IPG1 for deferral time.
13568c2ecf20Sopenharmony_ci						   IPG2 still used. */
13578c2ecf20Sopenharmony_ci#define    MAC_TX_CFG_NEVER_GIVE_UP_EN  0x0010  /* TX MAC will not easily
13588c2ecf20Sopenharmony_ci						   give up on frame
13598c2ecf20Sopenharmony_ci						   xmission. if backoff
13608c2ecf20Sopenharmony_ci						   algorithm reaches the
13618c2ecf20Sopenharmony_ci						   ATTEMPT_LIMIT, it will
13628c2ecf20Sopenharmony_ci						   clear attempts counter
13638c2ecf20Sopenharmony_ci						   and continue trying to
13648c2ecf20Sopenharmony_ci						   send the frame as
13658c2ecf20Sopenharmony_ci						   specified by
13668c2ecf20Sopenharmony_ci						   GIVE_UP_LIM. when 0,
13678c2ecf20Sopenharmony_ci						   TX MAC will execute
13688c2ecf20Sopenharmony_ci						   standard CSMA/CD prot. */
13698c2ecf20Sopenharmony_ci#define    MAC_TX_CFG_NEVER_GIVE_UP_LIM 0x0020  /* when set, TX MAC will
13708c2ecf20Sopenharmony_ci						   continue to try to xmit
13718c2ecf20Sopenharmony_ci						   until successful. when
13728c2ecf20Sopenharmony_ci						   0, TX MAC will continue
13738c2ecf20Sopenharmony_ci						   to try xmitting until
13748c2ecf20Sopenharmony_ci						   successful or backoff
13758c2ecf20Sopenharmony_ci						   algorithm reaches
13768c2ecf20Sopenharmony_ci						   ATTEMPT_LIMIT*16 */
13778c2ecf20Sopenharmony_ci#define    MAC_TX_CFG_NO_BACKOFF        0x0040  /* modify CSMA/CD to disable
13788c2ecf20Sopenharmony_ci						   backoff algorithm. TX
13798c2ecf20Sopenharmony_ci						   MAC will not back off
13808c2ecf20Sopenharmony_ci						   after a xmission attempt
13818c2ecf20Sopenharmony_ci						   that resulted in a
13828c2ecf20Sopenharmony_ci						   collision. */
13838c2ecf20Sopenharmony_ci#define    MAC_TX_CFG_SLOW_DOWN         0x0080  /* modify CSMA/CD so that
13848c2ecf20Sopenharmony_ci						   deferral process is reset
13858c2ecf20Sopenharmony_ci						   in response to carrier
13868c2ecf20Sopenharmony_ci						   sense during the entire
13878c2ecf20Sopenharmony_ci						   duration of IPG. TX MAC
13888c2ecf20Sopenharmony_ci						   will only commit to frame
13898c2ecf20Sopenharmony_ci						   xmission after frame
13908c2ecf20Sopenharmony_ci						   xmission has actually
13918c2ecf20Sopenharmony_ci						   begun. */
13928c2ecf20Sopenharmony_ci#define    MAC_TX_CFG_NO_FCS            0x0100  /* TX MAC will not generate
13938c2ecf20Sopenharmony_ci						   CRC for all xmitted
13948c2ecf20Sopenharmony_ci						   packets. when clear, CRC
13958c2ecf20Sopenharmony_ci						   generation is dependent
13968c2ecf20Sopenharmony_ci						   upon NO_CRC bit in the
13978c2ecf20Sopenharmony_ci						   xmit control word from
13988c2ecf20Sopenharmony_ci						   TX DMA */
13998c2ecf20Sopenharmony_ci#define    MAC_TX_CFG_CARRIER_EXTEND    0x0200  /* enables xmit part of the
14008c2ecf20Sopenharmony_ci						   carrier extension
14018c2ecf20Sopenharmony_ci						   feature. this allows for
14028c2ecf20Sopenharmony_ci						   longer collision domains
14038c2ecf20Sopenharmony_ci						   by extending the carrier
14048c2ecf20Sopenharmony_ci						   and collision window
14058c2ecf20Sopenharmony_ci						   from the end of FCS until
14068c2ecf20Sopenharmony_ci						   the end of the slot time
14078c2ecf20Sopenharmony_ci						   if necessary. Required
14088c2ecf20Sopenharmony_ci						   for half-duplex at 1Gbps,
14098c2ecf20Sopenharmony_ci						   clear otherwise. */
14108c2ecf20Sopenharmony_ci
14118c2ecf20Sopenharmony_ci/* when CRC is not stripped, reassembly packets will not contain the CRC.
14128c2ecf20Sopenharmony_ci * these will be stripped by HRP because it reassembles layer 4 data, and the
14138c2ecf20Sopenharmony_ci * CRC is layer 2. however, non-reassembly packets will still contain the CRC
14148c2ecf20Sopenharmony_ci * when passed to the host. to ensure proper operation, need to wait 3.2ms
14158c2ecf20Sopenharmony_ci * after clearing RX_CFG_EN before writing to any other RX MAC registers
14168c2ecf20Sopenharmony_ci * or other MAC parameters. alternatively, poll RX_CFG_EN until it clears
14178c2ecf20Sopenharmony_ci * to 0. similary, HASH_FILTER_EN and ADDR_FILTER_EN have the same
14188c2ecf20Sopenharmony_ci * restrictions as CFG_EN.
14198c2ecf20Sopenharmony_ci */
14208c2ecf20Sopenharmony_ci#define  REG_MAC_RX_CFG                 0x6034  /* RX MAC config reg */
14218c2ecf20Sopenharmony_ci#define    MAC_RX_CFG_EN                0x0001  /* enable RX MAC */
14228c2ecf20Sopenharmony_ci#define    MAC_RX_CFG_STRIP_PAD         0x0002  /* always program to 0.
14238c2ecf20Sopenharmony_ci						   feature not supported */
14248c2ecf20Sopenharmony_ci#define    MAC_RX_CFG_STRIP_FCS         0x0004  /* RX MAC will strip the
14258c2ecf20Sopenharmony_ci						   last 4 bytes of a
14268c2ecf20Sopenharmony_ci						   received frame. */
14278c2ecf20Sopenharmony_ci#define    MAC_RX_CFG_PROMISC_EN        0x0008  /* promiscuous mode */
14288c2ecf20Sopenharmony_ci#define    MAC_RX_CFG_PROMISC_GROUP_EN  0x0010  /* accept all valid
14298c2ecf20Sopenharmony_ci						   multicast frames (group
14308c2ecf20Sopenharmony_ci						   bit in DA field set) */
14318c2ecf20Sopenharmony_ci#define    MAC_RX_CFG_HASH_FILTER_EN    0x0020  /* use hash table to filter
14328c2ecf20Sopenharmony_ci						   multicast addresses */
14338c2ecf20Sopenharmony_ci#define    MAC_RX_CFG_ADDR_FILTER_EN    0x0040  /* cause RX MAC to use
14348c2ecf20Sopenharmony_ci						   address filtering regs
14358c2ecf20Sopenharmony_ci						   to filter both unicast
14368c2ecf20Sopenharmony_ci						   and multicast
14378c2ecf20Sopenharmony_ci						   addresses */
14388c2ecf20Sopenharmony_ci#define    MAC_RX_CFG_DISABLE_DISCARD   0x0080  /* pass errored frames to
14398c2ecf20Sopenharmony_ci						   RX DMA by setting BAD
14408c2ecf20Sopenharmony_ci						   bit but not Abort bit
14418c2ecf20Sopenharmony_ci						   in the status. CRC,
14428c2ecf20Sopenharmony_ci						   framing, and length errs
14438c2ecf20Sopenharmony_ci						   will not increment
14448c2ecf20Sopenharmony_ci						   error counters. frames
14458c2ecf20Sopenharmony_ci						   which don't match dest
14468c2ecf20Sopenharmony_ci						   addr will be passed up
14478c2ecf20Sopenharmony_ci						   w/ BAD bit set. */
14488c2ecf20Sopenharmony_ci#define    MAC_RX_CFG_CARRIER_EXTEND    0x0100  /* enable reception of
14498c2ecf20Sopenharmony_ci						   packet bursts generated
14508c2ecf20Sopenharmony_ci						   by carrier extension
14518c2ecf20Sopenharmony_ci						   with packet bursting
14528c2ecf20Sopenharmony_ci						   senders. only applies
14538c2ecf20Sopenharmony_ci						   to half-duplex 1Gbps */
14548c2ecf20Sopenharmony_ci
14558c2ecf20Sopenharmony_ci/* DEFAULT: 0x0 */
14568c2ecf20Sopenharmony_ci#define  REG_MAC_CTRL_CFG               0x6038  /* MAC control config reg */
14578c2ecf20Sopenharmony_ci#define    MAC_CTRL_CFG_SEND_PAUSE_EN   0x0001  /* respond to requests for
14588c2ecf20Sopenharmony_ci						   sending pause flow ctrl
14598c2ecf20Sopenharmony_ci						   frames */
14608c2ecf20Sopenharmony_ci#define    MAC_CTRL_CFG_RECV_PAUSE_EN   0x0002  /* respond to received
14618c2ecf20Sopenharmony_ci						   pause flow ctrl frames */
14628c2ecf20Sopenharmony_ci#define    MAC_CTRL_CFG_PASS_CTRL       0x0004  /* pass valid MAC ctrl
14638c2ecf20Sopenharmony_ci						   packets to RX DMA */
14648c2ecf20Sopenharmony_ci
14658c2ecf20Sopenharmony_ci/* to ensure proper operation, a global initialization sequence should be
14668c2ecf20Sopenharmony_ci * performed when a loopback config is entered or exited. if programmed after
14678c2ecf20Sopenharmony_ci * a hw or global sw reset, RX/TX MAC software reset and initialization
14688c2ecf20Sopenharmony_ci * should be done to ensure stable clocking.
14698c2ecf20Sopenharmony_ci * DEFAULT: 0x0
14708c2ecf20Sopenharmony_ci */
14718c2ecf20Sopenharmony_ci#define  REG_MAC_XIF_CFG                0x603C  /* XIF config reg */
14728c2ecf20Sopenharmony_ci#define    MAC_XIF_TX_MII_OUTPUT_EN        0x0001  /* enable output drivers
14738c2ecf20Sopenharmony_ci						      on MII xmit bus */
14748c2ecf20Sopenharmony_ci#define    MAC_XIF_MII_INT_LOOPBACK        0x0002  /* loopback GMII xmit data
14758c2ecf20Sopenharmony_ci						      path to GMII recv data
14768c2ecf20Sopenharmony_ci						      path. phy mode register
14778c2ecf20Sopenharmony_ci						      clock selection must be
14788c2ecf20Sopenharmony_ci						      set to GMII mode and
14798c2ecf20Sopenharmony_ci						      GMII_MODE should be set
14808c2ecf20Sopenharmony_ci						      to 1. in loopback mode,
14818c2ecf20Sopenharmony_ci						      REFCLK will drive the
14828c2ecf20Sopenharmony_ci						      entire mac core. 0 for
14838c2ecf20Sopenharmony_ci						      normal operation. */
14848c2ecf20Sopenharmony_ci#define    MAC_XIF_DISABLE_ECHO            0x0004  /* disables receive data
14858c2ecf20Sopenharmony_ci						      path during packet
14868c2ecf20Sopenharmony_ci						      xmission. clear to 0
14878c2ecf20Sopenharmony_ci						      in any full duplex mode,
14888c2ecf20Sopenharmony_ci						      in any loopback mode,
14898c2ecf20Sopenharmony_ci						      or in half-duplex SERDES
14908c2ecf20Sopenharmony_ci						      or SLINK modes. set when
14918c2ecf20Sopenharmony_ci						      in half-duplex when
14928c2ecf20Sopenharmony_ci						      using external phy. */
14938c2ecf20Sopenharmony_ci#define    MAC_XIF_GMII_MODE               0x0008  /* MAC operates with GMII
14948c2ecf20Sopenharmony_ci						      clocks and datapath */
14958c2ecf20Sopenharmony_ci#define    MAC_XIF_MII_BUFFER_OUTPUT_EN    0x0010  /* MII_BUF_EN pin. enable
14968c2ecf20Sopenharmony_ci						      external tristate buffer
14978c2ecf20Sopenharmony_ci						      on the MII receive
14988c2ecf20Sopenharmony_ci						      bus. */
14998c2ecf20Sopenharmony_ci#define    MAC_XIF_LINK_LED                0x0020  /* LINKLED# active (low) */
15008c2ecf20Sopenharmony_ci#define    MAC_XIF_FDPLX_LED               0x0040  /* FDPLXLED# active (low) */
15018c2ecf20Sopenharmony_ci
15028c2ecf20Sopenharmony_ci#define  REG_MAC_IPG0                      0x6040  /* inter-packet gap0 reg.
15038c2ecf20Sopenharmony_ci						      recommended: 0x00 */
15048c2ecf20Sopenharmony_ci#define  REG_MAC_IPG1                      0x6044  /* inter-packet gap1 reg
15058c2ecf20Sopenharmony_ci						      recommended: 0x08 */
15068c2ecf20Sopenharmony_ci#define  REG_MAC_IPG2                      0x6048  /* inter-packet gap2 reg
15078c2ecf20Sopenharmony_ci						      recommended: 0x04 */
15088c2ecf20Sopenharmony_ci#define  REG_MAC_SLOT_TIME                 0x604C  /* slot time reg
15098c2ecf20Sopenharmony_ci						      recommended: 0x40 */
15108c2ecf20Sopenharmony_ci#define  REG_MAC_FRAMESIZE_MIN             0x6050  /* min frame size reg
15118c2ecf20Sopenharmony_ci						      recommended: 0x40 */
15128c2ecf20Sopenharmony_ci
15138c2ecf20Sopenharmony_ci/* FRAMESIZE_MAX holds both the max frame size as well as the max burst size.
15148c2ecf20Sopenharmony_ci * recommended value:  0x2000.05EE
15158c2ecf20Sopenharmony_ci */
15168c2ecf20Sopenharmony_ci#define  REG_MAC_FRAMESIZE_MAX             0x6054  /* max frame size reg */
15178c2ecf20Sopenharmony_ci#define    MAC_FRAMESIZE_MAX_BURST_MASK    0x3FFF0000 /* max burst size */
15188c2ecf20Sopenharmony_ci#define    MAC_FRAMESIZE_MAX_BURST_SHIFT   16
15198c2ecf20Sopenharmony_ci#define    MAC_FRAMESIZE_MAX_FRAME_MASK    0x00007FFF /* max frame size */
15208c2ecf20Sopenharmony_ci#define    MAC_FRAMESIZE_MAX_FRAME_SHIFT   0
15218c2ecf20Sopenharmony_ci#define  REG_MAC_PA_SIZE                   0x6058  /* PA size reg. number of
15228c2ecf20Sopenharmony_ci						      preamble bytes that the
15238c2ecf20Sopenharmony_ci						      TX MAC will xmit at the
15248c2ecf20Sopenharmony_ci						      beginning of each frame
15258c2ecf20Sopenharmony_ci						      value should be 2 or
15268c2ecf20Sopenharmony_ci						      greater. recommended
15278c2ecf20Sopenharmony_ci						      value: 0x07 */
15288c2ecf20Sopenharmony_ci#define  REG_MAC_JAM_SIZE                  0x605C  /* jam size reg. duration
15298c2ecf20Sopenharmony_ci						      of jam in units of media
15308c2ecf20Sopenharmony_ci						      byte time. recommended
15318c2ecf20Sopenharmony_ci						      value: 0x04 */
15328c2ecf20Sopenharmony_ci#define  REG_MAC_ATTEMPT_LIMIT             0x6060  /* attempt limit reg. #
15338c2ecf20Sopenharmony_ci						      of attempts TX MAC will
15348c2ecf20Sopenharmony_ci						      make to xmit a frame
15358c2ecf20Sopenharmony_ci						      before it resets its
15368c2ecf20Sopenharmony_ci						      attempts counter. after
15378c2ecf20Sopenharmony_ci						      the limit has been
15388c2ecf20Sopenharmony_ci						      reached, TX MAC may or
15398c2ecf20Sopenharmony_ci						      may not drop the frame
15408c2ecf20Sopenharmony_ci						      dependent upon value
15418c2ecf20Sopenharmony_ci						      in TX_MAC_CFG.
15428c2ecf20Sopenharmony_ci						      recommended
15438c2ecf20Sopenharmony_ci						      value: 0x10 */
15448c2ecf20Sopenharmony_ci#define  REG_MAC_CTRL_TYPE                 0x6064  /* MAC control type reg.
15458c2ecf20Sopenharmony_ci						      type field of a MAC
15468c2ecf20Sopenharmony_ci						      ctrl frame. recommended
15478c2ecf20Sopenharmony_ci						      value: 0x8808 */
15488c2ecf20Sopenharmony_ci
15498c2ecf20Sopenharmony_ci/* mac address registers: 0 - 44, 0x6080 - 0x6130, 4 8-bit bytes.
15508c2ecf20Sopenharmony_ci * register           contains                   comparison
15518c2ecf20Sopenharmony_ci *    0        16 MSB of primary MAC addr        [47:32] of DA field
15528c2ecf20Sopenharmony_ci *    1        16 middle bits ""                 [31:16] of DA field
15538c2ecf20Sopenharmony_ci *    2        16 LSB ""                         [15:0] of DA field
15548c2ecf20Sopenharmony_ci *    3*x      16MSB of alt MAC addr 1-15        [47:32] of DA field
15558c2ecf20Sopenharmony_ci *    4*x      16 middle bits ""                 [31:16]
15568c2ecf20Sopenharmony_ci *    5*x      16 LSB ""                         [15:0]
15578c2ecf20Sopenharmony_ci *    42       16 MSB of MAC CTRL addr           [47:32] of DA.
15588c2ecf20Sopenharmony_ci *    43       16 middle bits ""                 [31:16]
15598c2ecf20Sopenharmony_ci *    44       16 LSB ""                         [15:0]
15608c2ecf20Sopenharmony_ci *    MAC CTRL addr must be the reserved multicast addr for MAC CTRL frames.
15618c2ecf20Sopenharmony_ci *    if there is a match, MAC will set the bit for alternative address
15628c2ecf20Sopenharmony_ci *    filter pass [15]
15638c2ecf20Sopenharmony_ci
15648c2ecf20Sopenharmony_ci *    here is the map of registers given MAC address notation: a:b:c:d:e:f
15658c2ecf20Sopenharmony_ci *                     ab             cd             ef
15668c2ecf20Sopenharmony_ci *    primary addr     reg 2          reg 1          reg 0
15678c2ecf20Sopenharmony_ci *    alt addr 1       reg 5          reg 4          reg 3
15688c2ecf20Sopenharmony_ci *    alt addr x       reg 5*x        reg 4*x        reg 3*x
15698c2ecf20Sopenharmony_ci *    ctrl addr        reg 44         reg 43         reg 42
15708c2ecf20Sopenharmony_ci */
15718c2ecf20Sopenharmony_ci#define  REG_MAC_ADDR0                     0x6080  /* MAC address 0 reg */
15728c2ecf20Sopenharmony_ci#define  REG_MAC_ADDRN(x)                  (REG_MAC_ADDR0 + (x)*4)
15738c2ecf20Sopenharmony_ci#define  REG_MAC_ADDR_FILTER0              0x614C  /* address filter 0 reg
15748c2ecf20Sopenharmony_ci						      [47:32] */
15758c2ecf20Sopenharmony_ci#define  REG_MAC_ADDR_FILTER1              0x6150  /* address filter 1 reg
15768c2ecf20Sopenharmony_ci						      [31:16] */
15778c2ecf20Sopenharmony_ci#define  REG_MAC_ADDR_FILTER2              0x6154  /* address filter 2 reg
15788c2ecf20Sopenharmony_ci						      [15:0] */
15798c2ecf20Sopenharmony_ci#define  REG_MAC_ADDR_FILTER2_1_MASK       0x6158  /* address filter 2 and 1
15808c2ecf20Sopenharmony_ci						      mask reg. 8-bit reg
15818c2ecf20Sopenharmony_ci						      contains nibble mask for
15828c2ecf20Sopenharmony_ci						      reg 2 and 1. */
15838c2ecf20Sopenharmony_ci#define  REG_MAC_ADDR_FILTER0_MASK         0x615C  /* address filter 0 mask
15848c2ecf20Sopenharmony_ci						      reg */
15858c2ecf20Sopenharmony_ci
15868c2ecf20Sopenharmony_ci/* hash table registers: 0 - 15, 0x6160 - 0x619C, 4 8-bit bytes
15878c2ecf20Sopenharmony_ci * 16-bit registers contain bits of the hash table.
15888c2ecf20Sopenharmony_ci * reg x  -> [16*(15 - x) + 15 : 16*(15 - x)].
15898c2ecf20Sopenharmony_ci * e.g., 15 -> [15:0], 0 -> [255:240]
15908c2ecf20Sopenharmony_ci */
15918c2ecf20Sopenharmony_ci#define  REG_MAC_HASH_TABLE0               0x6160  /* hash table 0 reg */
15928c2ecf20Sopenharmony_ci#define  REG_MAC_HASH_TABLEN(x)            (REG_MAC_HASH_TABLE0 + (x)*4)
15938c2ecf20Sopenharmony_ci
15948c2ecf20Sopenharmony_ci/* statistics registers. these registers generate an interrupt on
15958c2ecf20Sopenharmony_ci * overflow. recommended initialization: 0x0000. most are 16-bits except
15968c2ecf20Sopenharmony_ci * for PEAK_ATTEMPTS register which is 8 bits.
15978c2ecf20Sopenharmony_ci */
15988c2ecf20Sopenharmony_ci#define  REG_MAC_COLL_NORMAL               0x61A0 /* normal collision
15998c2ecf20Sopenharmony_ci						     counter. */
16008c2ecf20Sopenharmony_ci#define  REG_MAC_COLL_FIRST                0x61A4 /* first attempt
16018c2ecf20Sopenharmony_ci						     successful collision
16028c2ecf20Sopenharmony_ci						     counter */
16038c2ecf20Sopenharmony_ci#define  REG_MAC_COLL_EXCESS               0x61A8 /* excessive collision
16048c2ecf20Sopenharmony_ci						     counter */
16058c2ecf20Sopenharmony_ci#define  REG_MAC_COLL_LATE                 0x61AC /* late collision counter */
16068c2ecf20Sopenharmony_ci#define  REG_MAC_TIMER_DEFER               0x61B0 /* defer timer. time base
16078c2ecf20Sopenharmony_ci						     is the media byte
16088c2ecf20Sopenharmony_ci						     clock/256 */
16098c2ecf20Sopenharmony_ci#define  REG_MAC_ATTEMPTS_PEAK             0x61B4 /* peak attempts reg */
16108c2ecf20Sopenharmony_ci#define  REG_MAC_RECV_FRAME                0x61B8 /* receive frame counter */
16118c2ecf20Sopenharmony_ci#define  REG_MAC_LEN_ERR                   0x61BC /* length error counter */
16128c2ecf20Sopenharmony_ci#define  REG_MAC_ALIGN_ERR                 0x61C0 /* alignment error counter */
16138c2ecf20Sopenharmony_ci#define  REG_MAC_FCS_ERR                   0x61C4 /* FCS error counter */
16148c2ecf20Sopenharmony_ci#define  REG_MAC_RX_CODE_ERR               0x61C8 /* RX code violation
16158c2ecf20Sopenharmony_ci						     error counter */
16168c2ecf20Sopenharmony_ci
16178c2ecf20Sopenharmony_ci/* misc registers */
16188c2ecf20Sopenharmony_ci#define  REG_MAC_RANDOM_SEED               0x61CC /* random number seed reg.
16198c2ecf20Sopenharmony_ci						   10-bit register used as a
16208c2ecf20Sopenharmony_ci						   seed  for the random number
16218c2ecf20Sopenharmony_ci						   generator for the CSMA/CD
16228c2ecf20Sopenharmony_ci						   backoff algorithm. only
16238c2ecf20Sopenharmony_ci						   programmed after power-on
16248c2ecf20Sopenharmony_ci						   reset and should be a
16258c2ecf20Sopenharmony_ci						   random value which has a
16268c2ecf20Sopenharmony_ci						   high likelihood of being
16278c2ecf20Sopenharmony_ci						   unique for each MAC
16288c2ecf20Sopenharmony_ci						   attached to a network
16298c2ecf20Sopenharmony_ci						   segment (e.g., 10 LSB of
16308c2ecf20Sopenharmony_ci						   MAC address) */
16318c2ecf20Sopenharmony_ci
16328c2ecf20Sopenharmony_ci/* ASUN: there's a PAUSE_TIMER (ro) described, but it's not in the address
16338c2ecf20Sopenharmony_ci *       map
16348c2ecf20Sopenharmony_ci */
16358c2ecf20Sopenharmony_ci
16368c2ecf20Sopenharmony_ci/* 27-bit register has the current state for key state machines in the MAC */
16378c2ecf20Sopenharmony_ci#define  REG_MAC_STATE_MACHINE             0x61D0 /* (ro) state machine reg */
16388c2ecf20Sopenharmony_ci#define    MAC_SM_RLM_MASK                 0x07800000
16398c2ecf20Sopenharmony_ci#define    MAC_SM_RLM_SHIFT                23
16408c2ecf20Sopenharmony_ci#define    MAC_SM_RX_FC_MASK               0x00700000
16418c2ecf20Sopenharmony_ci#define    MAC_SM_RX_FC_SHIFT              20
16428c2ecf20Sopenharmony_ci#define    MAC_SM_TLM_MASK                 0x000F0000
16438c2ecf20Sopenharmony_ci#define    MAC_SM_TLM_SHIFT                16
16448c2ecf20Sopenharmony_ci#define    MAC_SM_ENCAP_SM_MASK            0x0000F000
16458c2ecf20Sopenharmony_ci#define    MAC_SM_ENCAP_SM_SHIFT           12
16468c2ecf20Sopenharmony_ci#define    MAC_SM_TX_REQ_MASK              0x00000C00
16478c2ecf20Sopenharmony_ci#define    MAC_SM_TX_REQ_SHIFT             10
16488c2ecf20Sopenharmony_ci#define    MAC_SM_TX_FC_MASK               0x000003C0
16498c2ecf20Sopenharmony_ci#define    MAC_SM_TX_FC_SHIFT              6
16508c2ecf20Sopenharmony_ci#define    MAC_SM_FIFO_WRITE_SEL_MASK      0x00000038
16518c2ecf20Sopenharmony_ci#define    MAC_SM_FIFO_WRITE_SEL_SHIFT     3
16528c2ecf20Sopenharmony_ci#define    MAC_SM_TX_FIFO_EMPTY_MASK       0x00000007
16538c2ecf20Sopenharmony_ci#define    MAC_SM_TX_FIFO_EMPTY_SHIFT      0
16548c2ecf20Sopenharmony_ci
16558c2ecf20Sopenharmony_ci/** MIF registers. the MIF can be programmed in either bit-bang or
16568c2ecf20Sopenharmony_ci *  frame mode.
16578c2ecf20Sopenharmony_ci **/
16588c2ecf20Sopenharmony_ci#define  REG_MIF_BIT_BANG_CLOCK            0x6200 /* MIF bit-bang clock.
16598c2ecf20Sopenharmony_ci						   1 -> 0 will generate a
16608c2ecf20Sopenharmony_ci						   rising edge. 0 -> 1 will
16618c2ecf20Sopenharmony_ci						   generate a falling edge. */
16628c2ecf20Sopenharmony_ci#define  REG_MIF_BIT_BANG_DATA             0x6204 /* MIF bit-bang data. 1-bit
16638c2ecf20Sopenharmony_ci						     register generates data */
16648c2ecf20Sopenharmony_ci#define  REG_MIF_BIT_BANG_OUTPUT_EN        0x6208 /* MIF bit-bang output
16658c2ecf20Sopenharmony_ci						     enable. enable when
16668c2ecf20Sopenharmony_ci						     xmitting data from MIF to
16678c2ecf20Sopenharmony_ci						     transceiver. */
16688c2ecf20Sopenharmony_ci
16698c2ecf20Sopenharmony_ci/* 32-bit register serves as an instruction register when the MIF is
16708c2ecf20Sopenharmony_ci * programmed in frame mode. load this register w/ a valid instruction
16718c2ecf20Sopenharmony_ci * (as per IEEE 802.3u MII spec). poll this register to check for instruction
16728c2ecf20Sopenharmony_ci * execution completion. during a read operation, this register will also
16738c2ecf20Sopenharmony_ci * contain the 16-bit data returned by the tranceiver. unless specified
16748c2ecf20Sopenharmony_ci * otherwise, fields are considered "don't care" when polling for
16758c2ecf20Sopenharmony_ci * completion.
16768c2ecf20Sopenharmony_ci */
16778c2ecf20Sopenharmony_ci#define  REG_MIF_FRAME                     0x620C /* MIF frame/output reg */
16788c2ecf20Sopenharmony_ci#define    MIF_FRAME_START_MASK            0xC0000000 /* start of frame.
16798c2ecf20Sopenharmony_ci							 load w/ 01 when
16808c2ecf20Sopenharmony_ci							 issuing an instr */
16818c2ecf20Sopenharmony_ci#define    MIF_FRAME_ST                    0x40000000 /* STart of frame */
16828c2ecf20Sopenharmony_ci#define    MIF_FRAME_OPCODE_MASK           0x30000000 /* opcode. 01 for a
16838c2ecf20Sopenharmony_ci							 write. 10 for a
16848c2ecf20Sopenharmony_ci							 read */
16858c2ecf20Sopenharmony_ci#define    MIF_FRAME_OP_READ               0x20000000 /* read OPcode */
16868c2ecf20Sopenharmony_ci#define    MIF_FRAME_OP_WRITE              0x10000000 /* write OPcode */
16878c2ecf20Sopenharmony_ci#define    MIF_FRAME_PHY_ADDR_MASK         0x0F800000 /* phy address. when
16888c2ecf20Sopenharmony_ci							 issuing an instr,
16898c2ecf20Sopenharmony_ci							 this field should be
16908c2ecf20Sopenharmony_ci							 loaded w/ the XCVR
16918c2ecf20Sopenharmony_ci							 addr */
16928c2ecf20Sopenharmony_ci#define    MIF_FRAME_PHY_ADDR_SHIFT        23
16938c2ecf20Sopenharmony_ci#define    MIF_FRAME_REG_ADDR_MASK         0x007C0000 /* register address.
16948c2ecf20Sopenharmony_ci							 when issuing an instr,
16958c2ecf20Sopenharmony_ci							 addr of register
16968c2ecf20Sopenharmony_ci							 to be read/written */
16978c2ecf20Sopenharmony_ci#define    MIF_FRAME_REG_ADDR_SHIFT        18
16988c2ecf20Sopenharmony_ci#define    MIF_FRAME_TURN_AROUND_MSB       0x00020000 /* turn around, MSB.
16998c2ecf20Sopenharmony_ci							 when issuing an instr,
17008c2ecf20Sopenharmony_ci							 set this bit to 1 */
17018c2ecf20Sopenharmony_ci#define    MIF_FRAME_TURN_AROUND_LSB       0x00010000 /* turn around, LSB.
17028c2ecf20Sopenharmony_ci							 when issuing an instr,
17038c2ecf20Sopenharmony_ci							 set this bit to 0.
17048c2ecf20Sopenharmony_ci							 when polling for
17058c2ecf20Sopenharmony_ci							 completion, 1 means
17068c2ecf20Sopenharmony_ci							 that instr execution
17078c2ecf20Sopenharmony_ci							 has been completed */
17088c2ecf20Sopenharmony_ci#define    MIF_FRAME_DATA_MASK             0x0000FFFF /* instruction payload
17098c2ecf20Sopenharmony_ci							 load with 16-bit data
17108c2ecf20Sopenharmony_ci							 to be written in
17118c2ecf20Sopenharmony_ci							 transceiver reg for a
17128c2ecf20Sopenharmony_ci							 write. doesn't matter
17138c2ecf20Sopenharmony_ci							 in a read. when
17148c2ecf20Sopenharmony_ci							 polling for
17158c2ecf20Sopenharmony_ci							 completion, field is
17168c2ecf20Sopenharmony_ci							 "don't care" for write
17178c2ecf20Sopenharmony_ci							 and 16-bit data
17188c2ecf20Sopenharmony_ci							 returned by the
17198c2ecf20Sopenharmony_ci							 transceiver for a
17208c2ecf20Sopenharmony_ci							 read (if valid bit
17218c2ecf20Sopenharmony_ci							 is set) */
17228c2ecf20Sopenharmony_ci#define  REG_MIF_CFG                    0x6210 /* MIF config reg */
17238c2ecf20Sopenharmony_ci#define    MIF_CFG_PHY_SELECT           0x0001 /* 1 -> select MDIO_1
17248c2ecf20Sopenharmony_ci						  0 -> select MDIO_0 */
17258c2ecf20Sopenharmony_ci#define    MIF_CFG_POLL_EN              0x0002 /* enable polling
17268c2ecf20Sopenharmony_ci						  mechanism. if set,
17278c2ecf20Sopenharmony_ci						  BB_MODE should be 0 */
17288c2ecf20Sopenharmony_ci#define    MIF_CFG_BB_MODE              0x0004 /* 1 -> bit-bang mode
17298c2ecf20Sopenharmony_ci						  0 -> frame mode */
17308c2ecf20Sopenharmony_ci#define    MIF_CFG_POLL_REG_MASK        0x00F8 /* register address to be
17318c2ecf20Sopenharmony_ci						  used by polling mode.
17328c2ecf20Sopenharmony_ci						  only meaningful if POLL_EN
17338c2ecf20Sopenharmony_ci						  is set to 1 */
17348c2ecf20Sopenharmony_ci#define    MIF_CFG_POLL_REG_SHIFT       3
17358c2ecf20Sopenharmony_ci#define    MIF_CFG_MDIO_0               0x0100 /* (ro) dual purpose.
17368c2ecf20Sopenharmony_ci						  when MDIO_0 is idle,
17378c2ecf20Sopenharmony_ci						  1 -> tranceiver is
17388c2ecf20Sopenharmony_ci						  connected to MDIO_0.
17398c2ecf20Sopenharmony_ci						  when MIF is communicating
17408c2ecf20Sopenharmony_ci						  w/ MDIO_0 in bit-bang
17418c2ecf20Sopenharmony_ci						  mode, this bit indicates
17428c2ecf20Sopenharmony_ci						  the incoming bit stream
17438c2ecf20Sopenharmony_ci						  during a read op */
17448c2ecf20Sopenharmony_ci#define    MIF_CFG_MDIO_1               0x0200 /* (ro) dual purpose.
17458c2ecf20Sopenharmony_ci						  when MDIO_1 is idle,
17468c2ecf20Sopenharmony_ci						  1 -> transceiver is
17478c2ecf20Sopenharmony_ci						  connected to MDIO_1.
17488c2ecf20Sopenharmony_ci						  when MIF is communicating
17498c2ecf20Sopenharmony_ci						  w/ MDIO_1 in bit-bang
17508c2ecf20Sopenharmony_ci						  mode, this bit indicates
17518c2ecf20Sopenharmony_ci						  the incoming bit stream
17528c2ecf20Sopenharmony_ci						  during a read op */
17538c2ecf20Sopenharmony_ci#define    MIF_CFG_POLL_PHY_MASK        0x7C00 /* tranceiver address to
17548c2ecf20Sopenharmony_ci						  be polled */
17558c2ecf20Sopenharmony_ci#define    MIF_CFG_POLL_PHY_SHIFT       10
17568c2ecf20Sopenharmony_ci
17578c2ecf20Sopenharmony_ci/* 16-bit register used to determine which bits in the POLL_STATUS portion of
17588c2ecf20Sopenharmony_ci * the MIF_STATUS register will cause an interrupt. if a mask bit is 0,
17598c2ecf20Sopenharmony_ci * corresponding bit of the POLL_STATUS will generate a MIF interrupt when
17608c2ecf20Sopenharmony_ci * set. DEFAULT: 0xFFFF
17618c2ecf20Sopenharmony_ci */
17628c2ecf20Sopenharmony_ci#define  REG_MIF_MASK                      0x6214 /* MIF mask reg */
17638c2ecf20Sopenharmony_ci
17648c2ecf20Sopenharmony_ci/* 32-bit register used when in poll mode. auto-cleared after being read */
17658c2ecf20Sopenharmony_ci#define  REG_MIF_STATUS                    0x6218 /* MIF status reg */
17668c2ecf20Sopenharmony_ci#define    MIF_STATUS_POLL_DATA_MASK       0xFFFF0000 /* poll data contains
17678c2ecf20Sopenharmony_ci							 the "latest image"
17688c2ecf20Sopenharmony_ci							 update of the XCVR
17698c2ecf20Sopenharmony_ci							 reg being read */
17708c2ecf20Sopenharmony_ci#define    MIF_STATUS_POLL_DATA_SHIFT      16
17718c2ecf20Sopenharmony_ci#define    MIF_STATUS_POLL_STATUS_MASK     0x0000FFFF /* poll status indicates
17728c2ecf20Sopenharmony_ci							 which bits in the
17738c2ecf20Sopenharmony_ci							 POLL_DATA field have
17748c2ecf20Sopenharmony_ci							 changed since the
17758c2ecf20Sopenharmony_ci							 MIF_STATUS reg was
17768c2ecf20Sopenharmony_ci							 last read */
17778c2ecf20Sopenharmony_ci#define    MIF_STATUS_POLL_STATUS_SHIFT    0
17788c2ecf20Sopenharmony_ci
17798c2ecf20Sopenharmony_ci/* 7-bit register has current state for all state machines in the MIF */
17808c2ecf20Sopenharmony_ci#define  REG_MIF_STATE_MACHINE             0x621C /* MIF state machine reg */
17818c2ecf20Sopenharmony_ci#define    MIF_SM_CONTROL_MASK             0x07   /* control state machine
17828c2ecf20Sopenharmony_ci						     state */
17838c2ecf20Sopenharmony_ci#define    MIF_SM_EXECUTION_MASK           0x60   /* execution state machine
17848c2ecf20Sopenharmony_ci						     state */
17858c2ecf20Sopenharmony_ci
17868c2ecf20Sopenharmony_ci/** PCS/Serialink. the following registers are equivalent to the standard
17878c2ecf20Sopenharmony_ci *  MII management registers except that they're directly mapped in
17888c2ecf20Sopenharmony_ci *  Cassini's register space.
17898c2ecf20Sopenharmony_ci **/
17908c2ecf20Sopenharmony_ci
17918c2ecf20Sopenharmony_ci/* the auto-negotiation enable bit should be programmed the same at
17928c2ecf20Sopenharmony_ci * the link partner as in the local device to enable auto-negotiation to
17938c2ecf20Sopenharmony_ci * complete. when that bit is reprogrammed, auto-neg/manual config is
17948c2ecf20Sopenharmony_ci * restarted automatically.
17958c2ecf20Sopenharmony_ci * DEFAULT: 0x1040
17968c2ecf20Sopenharmony_ci */
17978c2ecf20Sopenharmony_ci#define  REG_PCS_MII_CTRL                  0x9000 /* PCS MII control reg */
17988c2ecf20Sopenharmony_ci#define    PCS_MII_CTRL_1000_SEL           0x0040 /* reads 1. ignored on
17998c2ecf20Sopenharmony_ci						     writes */
18008c2ecf20Sopenharmony_ci#define    PCS_MII_CTRL_COLLISION_TEST     0x0080 /* COL signal at the PCS
18018c2ecf20Sopenharmony_ci						     to MAC interface is
18028c2ecf20Sopenharmony_ci						     activated regardless
18038c2ecf20Sopenharmony_ci						     of activity */
18048c2ecf20Sopenharmony_ci#define    PCS_MII_CTRL_DUPLEX             0x0100 /* forced 0x0. PCS
18058c2ecf20Sopenharmony_ci						     behaviour same for
18068c2ecf20Sopenharmony_ci						     half and full dplx */
18078c2ecf20Sopenharmony_ci#define    PCS_MII_RESTART_AUTONEG         0x0200 /* self clearing.
18088c2ecf20Sopenharmony_ci						     restart auto-
18098c2ecf20Sopenharmony_ci						     negotiation */
18108c2ecf20Sopenharmony_ci#define    PCS_MII_ISOLATE                 0x0400 /* read as 0. ignored
18118c2ecf20Sopenharmony_ci						     on writes */
18128c2ecf20Sopenharmony_ci#define    PCS_MII_POWER_DOWN              0x0800 /* read as 0. ignored
18138c2ecf20Sopenharmony_ci						     on writes */
18148c2ecf20Sopenharmony_ci#define    PCS_MII_AUTONEG_EN              0x1000 /* default 1. PCS goes
18158c2ecf20Sopenharmony_ci						     through automatic
18168c2ecf20Sopenharmony_ci						     link config before it
18178c2ecf20Sopenharmony_ci						     can be used. when 0,
18188c2ecf20Sopenharmony_ci						     link can be used
18198c2ecf20Sopenharmony_ci						     w/out any link config
18208c2ecf20Sopenharmony_ci						     phase */
18218c2ecf20Sopenharmony_ci#define    PCS_MII_10_100_SEL              0x2000 /* read as 0. ignored on
18228c2ecf20Sopenharmony_ci						     writes */
18238c2ecf20Sopenharmony_ci#define    PCS_MII_RESET                   0x8000 /* reset PCS. self-clears
18248c2ecf20Sopenharmony_ci						     when done */
18258c2ecf20Sopenharmony_ci
18268c2ecf20Sopenharmony_ci/* DEFAULT: 0x0108 */
18278c2ecf20Sopenharmony_ci#define  REG_PCS_MII_STATUS                0x9004 /* PCS MII status reg */
18288c2ecf20Sopenharmony_ci#define    PCS_MII_STATUS_EXTEND_CAP       0x0001 /* reads 0 */
18298c2ecf20Sopenharmony_ci#define    PCS_MII_STATUS_JABBER_DETECT    0x0002 /* reads 0 */
18308c2ecf20Sopenharmony_ci#define    PCS_MII_STATUS_LINK_STATUS      0x0004 /* 1 -> link up.
18318c2ecf20Sopenharmony_ci						     0 -> link down. 0 is
18328c2ecf20Sopenharmony_ci						     latched so that 0 is
18338c2ecf20Sopenharmony_ci						     kept until read. read
18348c2ecf20Sopenharmony_ci						     2x to determine if the
18358c2ecf20Sopenharmony_ci						     link has gone up again */
18368c2ecf20Sopenharmony_ci#define    PCS_MII_STATUS_AUTONEG_ABLE     0x0008 /* reads 1 (able to perform
18378c2ecf20Sopenharmony_ci						     auto-neg) */
18388c2ecf20Sopenharmony_ci#define    PCS_MII_STATUS_REMOTE_FAULT     0x0010 /* 1 -> remote fault detected
18398c2ecf20Sopenharmony_ci						     from received link code
18408c2ecf20Sopenharmony_ci						     word. only valid after
18418c2ecf20Sopenharmony_ci						     auto-neg completed */
18428c2ecf20Sopenharmony_ci#define    PCS_MII_STATUS_AUTONEG_COMP     0x0020 /* 1 -> auto-negotiation
18438c2ecf20Sopenharmony_ci						          completed
18448c2ecf20Sopenharmony_ci						     0 -> auto-negotiation not
18458c2ecf20Sopenharmony_ci						     completed */
18468c2ecf20Sopenharmony_ci#define    PCS_MII_STATUS_EXTEND_STATUS    0x0100 /* reads as 1. used as an
18478c2ecf20Sopenharmony_ci						     indication that this is
18488c2ecf20Sopenharmony_ci						     a 1000 Base-X PHY. writes
18498c2ecf20Sopenharmony_ci						     to it are ignored */
18508c2ecf20Sopenharmony_ci
18518c2ecf20Sopenharmony_ci/* used during auto-negotiation.
18528c2ecf20Sopenharmony_ci * DEFAULT: 0x00E0
18538c2ecf20Sopenharmony_ci */
18548c2ecf20Sopenharmony_ci#define  REG_PCS_MII_ADVERT                0x9008 /* PCS MII advertisement
18558c2ecf20Sopenharmony_ci						     reg */
18568c2ecf20Sopenharmony_ci#define    PCS_MII_ADVERT_FD               0x0020  /* advertise full duplex
18578c2ecf20Sopenharmony_ci						      1000 Base-X */
18588c2ecf20Sopenharmony_ci#define    PCS_MII_ADVERT_HD               0x0040  /* advertise half-duplex
18598c2ecf20Sopenharmony_ci						      1000 Base-X */
18608c2ecf20Sopenharmony_ci#define    PCS_MII_ADVERT_SYM_PAUSE        0x0080  /* advertise PAUSE
18618c2ecf20Sopenharmony_ci						      symmetric capability */
18628c2ecf20Sopenharmony_ci#define    PCS_MII_ADVERT_ASYM_PAUSE       0x0100  /* advertises PAUSE
18638c2ecf20Sopenharmony_ci						      asymmetric capability */
18648c2ecf20Sopenharmony_ci#define    PCS_MII_ADVERT_RF_MASK          0x3000 /* remote fault. write bit13
18658c2ecf20Sopenharmony_ci						     to optionally indicate to
18668c2ecf20Sopenharmony_ci						     link partner that chip is
18678c2ecf20Sopenharmony_ci						     going off-line. bit12 will
18688c2ecf20Sopenharmony_ci						     get set when signal
18698c2ecf20Sopenharmony_ci						     detect == FAIL and will
18708c2ecf20Sopenharmony_ci						     remain set until
18718c2ecf20Sopenharmony_ci						     successful negotiation */
18728c2ecf20Sopenharmony_ci#define    PCS_MII_ADVERT_ACK              0x4000 /* (ro) */
18738c2ecf20Sopenharmony_ci#define    PCS_MII_ADVERT_NEXT_PAGE        0x8000 /* (ro) forced 0x0 */
18748c2ecf20Sopenharmony_ci
18758c2ecf20Sopenharmony_ci/* contents updated as a result of autonegotiation. layout and definitions
18768c2ecf20Sopenharmony_ci * identical to PCS_MII_ADVERT
18778c2ecf20Sopenharmony_ci */
18788c2ecf20Sopenharmony_ci#define  REG_PCS_MII_LPA                   0x900C /* PCS MII link partner
18798c2ecf20Sopenharmony_ci						     ability reg */
18808c2ecf20Sopenharmony_ci#define    PCS_MII_LPA_FD             PCS_MII_ADVERT_FD
18818c2ecf20Sopenharmony_ci#define    PCS_MII_LPA_HD             PCS_MII_ADVERT_HD
18828c2ecf20Sopenharmony_ci#define    PCS_MII_LPA_SYM_PAUSE      PCS_MII_ADVERT_SYM_PAUSE
18838c2ecf20Sopenharmony_ci#define    PCS_MII_LPA_ASYM_PAUSE     PCS_MII_ADVERT_ASYM_PAUSE
18848c2ecf20Sopenharmony_ci#define    PCS_MII_LPA_RF_MASK        PCS_MII_ADVERT_RF_MASK
18858c2ecf20Sopenharmony_ci#define    PCS_MII_LPA_ACK            PCS_MII_ADVERT_ACK
18868c2ecf20Sopenharmony_ci#define    PCS_MII_LPA_NEXT_PAGE      PCS_MII_ADVERT_NEXT_PAGE
18878c2ecf20Sopenharmony_ci
18888c2ecf20Sopenharmony_ci/* DEFAULT: 0x0 */
18898c2ecf20Sopenharmony_ci#define  REG_PCS_CFG                       0x9010 /* PCS config reg */
18908c2ecf20Sopenharmony_ci#define    PCS_CFG_EN                      0x01   /* enable PCS. must be
18918c2ecf20Sopenharmony_ci						     0 when modifying
18928c2ecf20Sopenharmony_ci						     PCS_MII_ADVERT */
18938c2ecf20Sopenharmony_ci#define    PCS_CFG_SD_OVERRIDE             0x02   /* sets signal detect to
18948c2ecf20Sopenharmony_ci						     OK. bit is
18958c2ecf20Sopenharmony_ci						     non-resettable */
18968c2ecf20Sopenharmony_ci#define    PCS_CFG_SD_ACTIVE_LOW           0x04   /* changes interpretation
18978c2ecf20Sopenharmony_ci						     of optical signal to make
18988c2ecf20Sopenharmony_ci						     signal detect okay when
18998c2ecf20Sopenharmony_ci						     signal is low */
19008c2ecf20Sopenharmony_ci#define    PCS_CFG_JITTER_STUDY_MASK       0x18   /* used to make jitter
19018c2ecf20Sopenharmony_ci						     measurements. a single
19028c2ecf20Sopenharmony_ci						     code group is xmitted
19038c2ecf20Sopenharmony_ci						     regularly.
19048c2ecf20Sopenharmony_ci						     0x0 = normal operation
19058c2ecf20Sopenharmony_ci						     0x1 = high freq test
19068c2ecf20Sopenharmony_ci						           pattern, D21.5
19078c2ecf20Sopenharmony_ci						     0x2 = low freq test
19088c2ecf20Sopenharmony_ci						           pattern, K28.7
19098c2ecf20Sopenharmony_ci						     0x3 = reserved */
19108c2ecf20Sopenharmony_ci#define    PCS_CFG_10MS_TIMER_OVERRIDE     0x20   /* shortens 10-20ms auto-
19118c2ecf20Sopenharmony_ci						     negotiation timer to
19128c2ecf20Sopenharmony_ci						     a few cycles for test
19138c2ecf20Sopenharmony_ci						     purposes */
19148c2ecf20Sopenharmony_ci
19158c2ecf20Sopenharmony_ci/* used for diagnostic purposes. bits 20-22 autoclear on read */
19168c2ecf20Sopenharmony_ci#define  REG_PCS_STATE_MACHINE             0x9014 /* (ro) PCS state machine
19178c2ecf20Sopenharmony_ci						     and diagnostic reg */
19188c2ecf20Sopenharmony_ci#define    PCS_SM_TX_STATE_MASK            0x0000000F /* 0 and 1 indicate
19198c2ecf20Sopenharmony_ci							 xmission of idle.
19208c2ecf20Sopenharmony_ci							 otherwise, xmission of
19218c2ecf20Sopenharmony_ci							 a packet */
19228c2ecf20Sopenharmony_ci#define    PCS_SM_RX_STATE_MASK            0x000000F0 /* 0 indicates reception
19238c2ecf20Sopenharmony_ci							 of idle. otherwise,
19248c2ecf20Sopenharmony_ci							 reception of packet */
19258c2ecf20Sopenharmony_ci#define    PCS_SM_WORD_SYNC_STATE_MASK     0x00000700 /* 0 indicates loss of
19268c2ecf20Sopenharmony_ci							 sync */
19278c2ecf20Sopenharmony_ci#define    PCS_SM_SEQ_DETECT_STATE_MASK    0x00001800 /* cycling through 0-3
19288c2ecf20Sopenharmony_ci							 indicates reception of
19298c2ecf20Sopenharmony_ci							 Config codes. cycling
19308c2ecf20Sopenharmony_ci							 through 0-1 indicates
19318c2ecf20Sopenharmony_ci							 reception of idles */
19328c2ecf20Sopenharmony_ci#define    PCS_SM_LINK_STATE_MASK          0x0001E000
19338c2ecf20Sopenharmony_ci#define        SM_LINK_STATE_UP            0x00016000 /* link state is up */
19348c2ecf20Sopenharmony_ci
19358c2ecf20Sopenharmony_ci#define    PCS_SM_LOSS_LINK_C              0x00100000 /* loss of link due to
19368c2ecf20Sopenharmony_ci							 recept of Config
19378c2ecf20Sopenharmony_ci							 codes */
19388c2ecf20Sopenharmony_ci#define    PCS_SM_LOSS_LINK_SYNC           0x00200000 /* loss of link due to
19398c2ecf20Sopenharmony_ci							 loss of sync */
19408c2ecf20Sopenharmony_ci#define    PCS_SM_LOSS_SIGNAL_DETECT       0x00400000 /* signal detect goes
19418c2ecf20Sopenharmony_ci							 from OK to FAIL. bit29
19428c2ecf20Sopenharmony_ci							 will also be set if
19438c2ecf20Sopenharmony_ci							 this is set */
19448c2ecf20Sopenharmony_ci#define    PCS_SM_NO_LINK_BREAKLINK        0x01000000 /* link not up due to
19458c2ecf20Sopenharmony_ci							receipt of breaklink
19468c2ecf20Sopenharmony_ci							C codes from partner.
19478c2ecf20Sopenharmony_ci							C codes w/ 0 content
19488c2ecf20Sopenharmony_ci							received triggering
19498c2ecf20Sopenharmony_ci							start/restart of
19508c2ecf20Sopenharmony_ci							autonegotiation.
19518c2ecf20Sopenharmony_ci							should be sent for
19528c2ecf20Sopenharmony_ci							no longer than 20ms */
19538c2ecf20Sopenharmony_ci#define    PCS_SM_NO_LINK_SERDES           0x02000000 /* serdes being
19548c2ecf20Sopenharmony_ci							initialized. see serdes
19558c2ecf20Sopenharmony_ci							state reg */
19568c2ecf20Sopenharmony_ci#define    PCS_SM_NO_LINK_C                0x04000000 /* C codes not stable or
19578c2ecf20Sopenharmony_ci							 not received */
19588c2ecf20Sopenharmony_ci#define    PCS_SM_NO_LINK_SYNC             0x08000000 /* word sync not
19598c2ecf20Sopenharmony_ci							 achieved */
19608c2ecf20Sopenharmony_ci#define    PCS_SM_NO_LINK_WAIT_C           0x10000000 /* waiting for C codes
19618c2ecf20Sopenharmony_ci							 w/ ack bit set */
19628c2ecf20Sopenharmony_ci#define    PCS_SM_NO_LINK_NO_IDLE          0x20000000 /* link partner continues
19638c2ecf20Sopenharmony_ci							 to send C codes
19648c2ecf20Sopenharmony_ci							 instead of idle
19658c2ecf20Sopenharmony_ci							 symbols or pkt data */
19668c2ecf20Sopenharmony_ci
19678c2ecf20Sopenharmony_ci/* this register indicates interrupt changes in specific PCS MII status bits.
19688c2ecf20Sopenharmony_ci * PCS_INT may be masked at the ISR level. only a single bit is implemented
19698c2ecf20Sopenharmony_ci * for link status change.
19708c2ecf20Sopenharmony_ci */
19718c2ecf20Sopenharmony_ci#define  REG_PCS_INTR_STATUS               0x9018 /* PCS interrupt status */
19728c2ecf20Sopenharmony_ci#define    PCS_INTR_STATUS_LINK_CHANGE     0x04   /* link status has changed
19738c2ecf20Sopenharmony_ci						     since last read */
19748c2ecf20Sopenharmony_ci
19758c2ecf20Sopenharmony_ci/* control which network interface is used. no more than one bit should
19768c2ecf20Sopenharmony_ci * be set.
19778c2ecf20Sopenharmony_ci * DEFAULT: none
19788c2ecf20Sopenharmony_ci */
19798c2ecf20Sopenharmony_ci#define  REG_PCS_DATAPATH_MODE             0x9050 /* datapath mode reg */
19808c2ecf20Sopenharmony_ci#define    PCS_DATAPATH_MODE_MII           0x00 /* PCS is not used and
19818c2ecf20Sopenharmony_ci						   MII/GMII is selected.
19828c2ecf20Sopenharmony_ci						   selection between MII and
19838c2ecf20Sopenharmony_ci						   GMII is controlled by
19848c2ecf20Sopenharmony_ci						   XIF_CFG */
19858c2ecf20Sopenharmony_ci#define    PCS_DATAPATH_MODE_SERDES        0x02 /* PCS is used via the
19868c2ecf20Sopenharmony_ci						   10-bit interface */
19878c2ecf20Sopenharmony_ci
19888c2ecf20Sopenharmony_ci/* input to serdes chip or serialink block */
19898c2ecf20Sopenharmony_ci#define  REG_PCS_SERDES_CTRL              0x9054 /* serdes control reg */
19908c2ecf20Sopenharmony_ci#define    PCS_SERDES_CTRL_LOOPBACK       0x01   /* enable loopback on
19918c2ecf20Sopenharmony_ci						    serdes interface */
19928c2ecf20Sopenharmony_ci#define    PCS_SERDES_CTRL_SYNCD_EN       0x02   /* enable sync carrier
19938c2ecf20Sopenharmony_ci						    detection. should be
19948c2ecf20Sopenharmony_ci						    0x0 for normal
19958c2ecf20Sopenharmony_ci						    operation */
19968c2ecf20Sopenharmony_ci#define    PCS_SERDES_CTRL_LOCKREF       0x04   /* frequency-lock RBC[0:1]
19978c2ecf20Sopenharmony_ci						   to REFCLK when set.
19988c2ecf20Sopenharmony_ci						   when clear, receiver
19998c2ecf20Sopenharmony_ci						   clock locks to incoming
20008c2ecf20Sopenharmony_ci						   serial data */
20018c2ecf20Sopenharmony_ci
20028c2ecf20Sopenharmony_ci/* multiplex test outputs into the PROM address (PA_3 through PA_0) pins.
20038c2ecf20Sopenharmony_ci * should be 0x0 for normal operations.
20048c2ecf20Sopenharmony_ci * 0b000          normal operation, PROM address[3:0] selected
20058c2ecf20Sopenharmony_ci * 0b001          rxdma req, rxdma ack, rxdma ready, rxdma read
20068c2ecf20Sopenharmony_ci * 0b010          rxmac req, rx ack, rx tag, rx clk shared
20078c2ecf20Sopenharmony_ci * 0b011          txmac req, tx ack, tx tag, tx retry req
20088c2ecf20Sopenharmony_ci * 0b100          tx tp3, tx tp2, tx tp1, tx tp0
20098c2ecf20Sopenharmony_ci * 0b101          R period RX, R period TX, R period HP, R period BIM
20108c2ecf20Sopenharmony_ci * DEFAULT: 0x0
20118c2ecf20Sopenharmony_ci */
20128c2ecf20Sopenharmony_ci#define  REG_PCS_SHARED_OUTPUT_SEL         0x9058 /* shared output select */
20138c2ecf20Sopenharmony_ci#define    PCS_SOS_PROM_ADDR_MASK          0x0007
20148c2ecf20Sopenharmony_ci
20158c2ecf20Sopenharmony_ci/* used for diagnostics. this register indicates progress of the SERDES
20168c2ecf20Sopenharmony_ci * boot up.
20178c2ecf20Sopenharmony_ci * 0b00       undergoing reset
20188c2ecf20Sopenharmony_ci * 0b01       waiting 500us while lockrefn is asserted
20198c2ecf20Sopenharmony_ci * 0b10       waiting for comma detect
20208c2ecf20Sopenharmony_ci * 0b11       receive data is synchronized
20218c2ecf20Sopenharmony_ci * DEFAULT: 0x0
20228c2ecf20Sopenharmony_ci */
20238c2ecf20Sopenharmony_ci#define  REG_PCS_SERDES_STATE              0x905C /* (ro) serdes state */
20248c2ecf20Sopenharmony_ci#define    PCS_SERDES_STATE_MASK           0x03
20258c2ecf20Sopenharmony_ci
20268c2ecf20Sopenharmony_ci/* used for diagnostics. indicates number of packets transmitted or received.
20278c2ecf20Sopenharmony_ci * counters rollover w/out generating an interrupt.
20288c2ecf20Sopenharmony_ci * DEFAULT: 0x0
20298c2ecf20Sopenharmony_ci */
20308c2ecf20Sopenharmony_ci#define  REG_PCS_PACKET_COUNT              0x9060 /* (ro) PCS packet counter */
20318c2ecf20Sopenharmony_ci#define    PCS_PACKET_COUNT_TX             0x000007FF /* pkts xmitted by PCS */
20328c2ecf20Sopenharmony_ci#define    PCS_PACKET_COUNT_RX             0x07FF0000 /* pkts recvd by PCS
20338c2ecf20Sopenharmony_ci							 whether they
20348c2ecf20Sopenharmony_ci							 encountered an error
20358c2ecf20Sopenharmony_ci							 or not */
20368c2ecf20Sopenharmony_ci
20378c2ecf20Sopenharmony_ci/** LocalBus Devices. the following provides run-time access to the
20388c2ecf20Sopenharmony_ci *  Cassini's PROM
20398c2ecf20Sopenharmony_ci ***/
20408c2ecf20Sopenharmony_ci#define  REG_EXPANSION_ROM_RUN_START       0x100000 /* expansion rom run time
20418c2ecf20Sopenharmony_ci						       access */
20428c2ecf20Sopenharmony_ci#define  REG_EXPANSION_ROM_RUN_END         0x17FFFF
20438c2ecf20Sopenharmony_ci
20448c2ecf20Sopenharmony_ci#define  REG_SECOND_LOCALBUS_START         0x180000 /* secondary local bus
20458c2ecf20Sopenharmony_ci						       device */
20468c2ecf20Sopenharmony_ci#define  REG_SECOND_LOCALBUS_END           0x1FFFFF
20478c2ecf20Sopenharmony_ci
20488c2ecf20Sopenharmony_ci/* entropy device */
20498c2ecf20Sopenharmony_ci#define  REG_ENTROPY_START                 REG_SECOND_LOCALBUS_START
20508c2ecf20Sopenharmony_ci#define  REG_ENTROPY_DATA                  (REG_ENTROPY_START + 0x00)
20518c2ecf20Sopenharmony_ci#define  REG_ENTROPY_STATUS                (REG_ENTROPY_START + 0x04)
20528c2ecf20Sopenharmony_ci#define      ENTROPY_STATUS_DRDY           0x01
20538c2ecf20Sopenharmony_ci#define      ENTROPY_STATUS_BUSY           0x02
20548c2ecf20Sopenharmony_ci#define      ENTROPY_STATUS_CIPHER         0x04
20558c2ecf20Sopenharmony_ci#define      ENTROPY_STATUS_BYPASS_MASK    0x18
20568c2ecf20Sopenharmony_ci#define  REG_ENTROPY_MODE                  (REG_ENTROPY_START + 0x05)
20578c2ecf20Sopenharmony_ci#define      ENTROPY_MODE_KEY_MASK         0x07
20588c2ecf20Sopenharmony_ci#define      ENTROPY_MODE_ENCRYPT          0x40
20598c2ecf20Sopenharmony_ci#define  REG_ENTROPY_RAND_REG              (REG_ENTROPY_START + 0x06)
20608c2ecf20Sopenharmony_ci#define  REG_ENTROPY_RESET                 (REG_ENTROPY_START + 0x07)
20618c2ecf20Sopenharmony_ci#define      ENTROPY_RESET_DES_IO          0x01
20628c2ecf20Sopenharmony_ci#define      ENTROPY_RESET_STC_MODE        0x02
20638c2ecf20Sopenharmony_ci#define      ENTROPY_RESET_KEY_CACHE       0x04
20648c2ecf20Sopenharmony_ci#define      ENTROPY_RESET_IV              0x08
20658c2ecf20Sopenharmony_ci#define  REG_ENTROPY_IV                    (REG_ENTROPY_START + 0x08)
20668c2ecf20Sopenharmony_ci#define  REG_ENTROPY_KEY0                  (REG_ENTROPY_START + 0x10)
20678c2ecf20Sopenharmony_ci#define  REG_ENTROPY_KEYN(x)               (REG_ENTROPY_KEY0 + 4*(x))
20688c2ecf20Sopenharmony_ci
20698c2ecf20Sopenharmony_ci/* phys of interest w/ their special mii registers */
20708c2ecf20Sopenharmony_ci#define PHY_LUCENT_B0     0x00437421
20718c2ecf20Sopenharmony_ci#define   LUCENT_MII_REG      0x1F
20728c2ecf20Sopenharmony_ci
20738c2ecf20Sopenharmony_ci#define PHY_NS_DP83065    0x20005c78
20748c2ecf20Sopenharmony_ci#define   DP83065_MII_MEM     0x16
20758c2ecf20Sopenharmony_ci#define   DP83065_MII_REGD    0x1D
20768c2ecf20Sopenharmony_ci#define   DP83065_MII_REGE    0x1E
20778c2ecf20Sopenharmony_ci
20788c2ecf20Sopenharmony_ci#define PHY_BROADCOM_5411 0x00206071
20798c2ecf20Sopenharmony_ci#define PHY_BROADCOM_B0   0x00206050
20808c2ecf20Sopenharmony_ci#define   BROADCOM_MII_REG4   0x14
20818c2ecf20Sopenharmony_ci#define   BROADCOM_MII_REG5   0x15
20828c2ecf20Sopenharmony_ci#define   BROADCOM_MII_REG7   0x17
20838c2ecf20Sopenharmony_ci#define   BROADCOM_MII_REG8   0x18
20848c2ecf20Sopenharmony_ci
20858c2ecf20Sopenharmony_ci#define   CAS_MII_ANNPTR          0x07
20868c2ecf20Sopenharmony_ci#define   CAS_MII_ANNPRR          0x08
20878c2ecf20Sopenharmony_ci#define   CAS_MII_1000_CTRL       0x09
20888c2ecf20Sopenharmony_ci#define   CAS_MII_1000_STATUS     0x0A
20898c2ecf20Sopenharmony_ci#define   CAS_MII_1000_EXTEND     0x0F
20908c2ecf20Sopenharmony_ci
20918c2ecf20Sopenharmony_ci#define   CAS_BMSR_1000_EXTEND    0x0100 /* supports 1000Base-T extended status */
20928c2ecf20Sopenharmony_ci/*
20938c2ecf20Sopenharmony_ci * if autoneg is disabled, here's the table:
20948c2ecf20Sopenharmony_ci * BMCR_SPEED100 = 100Mbps
20958c2ecf20Sopenharmony_ci * BMCR_SPEED1000 = 1000Mbps
20968c2ecf20Sopenharmony_ci * ~(BMCR_SPEED100 | BMCR_SPEED1000) = 10Mbps
20978c2ecf20Sopenharmony_ci */
20988c2ecf20Sopenharmony_ci#define   CAS_BMCR_SPEED1000      0x0040  /* Select 1000Mbps */
20998c2ecf20Sopenharmony_ci
21008c2ecf20Sopenharmony_ci#define   CAS_ADVERTISE_1000HALF   0x0100
21018c2ecf20Sopenharmony_ci#define   CAS_ADVERTISE_1000FULL   0x0200
21028c2ecf20Sopenharmony_ci#define   CAS_ADVERTISE_PAUSE      0x0400
21038c2ecf20Sopenharmony_ci#define   CAS_ADVERTISE_ASYM_PAUSE 0x0800
21048c2ecf20Sopenharmony_ci
21058c2ecf20Sopenharmony_ci/* regular lpa register */
21068c2ecf20Sopenharmony_ci#define   CAS_LPA_PAUSE	           CAS_ADVERTISE_PAUSE
21078c2ecf20Sopenharmony_ci#define   CAS_LPA_ASYM_PAUSE       CAS_ADVERTISE_ASYM_PAUSE
21088c2ecf20Sopenharmony_ci
21098c2ecf20Sopenharmony_ci/* 1000_STATUS register */
21108c2ecf20Sopenharmony_ci#define   CAS_LPA_1000HALF        0x0400
21118c2ecf20Sopenharmony_ci#define   CAS_LPA_1000FULL        0x0800
21128c2ecf20Sopenharmony_ci
21138c2ecf20Sopenharmony_ci#define   CAS_EXTEND_1000XFULL    0x8000
21148c2ecf20Sopenharmony_ci#define   CAS_EXTEND_1000XHALF    0x4000
21158c2ecf20Sopenharmony_ci#define   CAS_EXTEND_1000TFULL    0x2000
21168c2ecf20Sopenharmony_ci#define   CAS_EXTEND_1000THALF    0x1000
21178c2ecf20Sopenharmony_ci
21188c2ecf20Sopenharmony_ci/* cassini header parser firmware */
21198c2ecf20Sopenharmony_citypedef struct cas_hp_inst {
21208c2ecf20Sopenharmony_ci	const char *note;
21218c2ecf20Sopenharmony_ci
21228c2ecf20Sopenharmony_ci	u16 mask, val;
21238c2ecf20Sopenharmony_ci
21248c2ecf20Sopenharmony_ci	u8 op;
21258c2ecf20Sopenharmony_ci	u8 soff, snext;	/* if match succeeds, new offset and match */
21268c2ecf20Sopenharmony_ci	u8 foff, fnext;	/* if match fails, new offset and match */
21278c2ecf20Sopenharmony_ci	/* output info */
21288c2ecf20Sopenharmony_ci	u8 outop;    /* output opcode */
21298c2ecf20Sopenharmony_ci
21308c2ecf20Sopenharmony_ci	u16 outarg;  /* output argument */
21318c2ecf20Sopenharmony_ci	u8 outenab;  /* output enable: 0 = not, 1 = if match
21328c2ecf20Sopenharmony_ci			 2 = if !match, 3 = always */
21338c2ecf20Sopenharmony_ci	u8 outshift; /* barrel shift right, 4 bits */
21348c2ecf20Sopenharmony_ci	u16 outmask;
21358c2ecf20Sopenharmony_ci} cas_hp_inst_t;
21368c2ecf20Sopenharmony_ci
21378c2ecf20Sopenharmony_ci/* comparison */
21388c2ecf20Sopenharmony_ci#define OP_EQ     0 /* packet == value */
21398c2ecf20Sopenharmony_ci#define OP_LT     1 /* packet < value */
21408c2ecf20Sopenharmony_ci#define OP_GT     2 /* packet > value */
21418c2ecf20Sopenharmony_ci#define OP_NP     3 /* new packet */
21428c2ecf20Sopenharmony_ci
21438c2ecf20Sopenharmony_ci/* output opcodes */
21448c2ecf20Sopenharmony_ci#define	CL_REG	0
21458c2ecf20Sopenharmony_ci#define	LD_FID	1
21468c2ecf20Sopenharmony_ci#define	LD_SEQ	2
21478c2ecf20Sopenharmony_ci#define	LD_CTL	3
21488c2ecf20Sopenharmony_ci#define	LD_SAP	4
21498c2ecf20Sopenharmony_ci#define	LD_R1	5
21508c2ecf20Sopenharmony_ci#define	LD_L3	6
21518c2ecf20Sopenharmony_ci#define	LD_SUM	7
21528c2ecf20Sopenharmony_ci#define	LD_HDR	8
21538c2ecf20Sopenharmony_ci#define	IM_FID	9
21548c2ecf20Sopenharmony_ci#define	IM_SEQ	10
21558c2ecf20Sopenharmony_ci#define	IM_SAP	11
21568c2ecf20Sopenharmony_ci#define	IM_R1	12
21578c2ecf20Sopenharmony_ci#define	IM_CTL	13
21588c2ecf20Sopenharmony_ci#define	LD_LEN	14
21598c2ecf20Sopenharmony_ci#define	ST_FLG	15
21608c2ecf20Sopenharmony_ci
21618c2ecf20Sopenharmony_ci/* match setp #s for IP4TCP4 */
21628c2ecf20Sopenharmony_ci#define S1_PCKT         0
21638c2ecf20Sopenharmony_ci#define S1_VLAN         1
21648c2ecf20Sopenharmony_ci#define S1_CFI          2
21658c2ecf20Sopenharmony_ci#define S1_8023         3
21668c2ecf20Sopenharmony_ci#define S1_LLC          4
21678c2ecf20Sopenharmony_ci#define S1_LLCc         5
21688c2ecf20Sopenharmony_ci#define S1_IPV4         6
21698c2ecf20Sopenharmony_ci#define S1_IPV4c        7
21708c2ecf20Sopenharmony_ci#define S1_IPV4F        8
21718c2ecf20Sopenharmony_ci#define S1_TCP44        9
21728c2ecf20Sopenharmony_ci#define S1_IPV6         10
21738c2ecf20Sopenharmony_ci#define S1_IPV6L        11
21748c2ecf20Sopenharmony_ci#define S1_IPV6c        12
21758c2ecf20Sopenharmony_ci#define S1_TCP64        13
21768c2ecf20Sopenharmony_ci#define S1_TCPSQ        14
21778c2ecf20Sopenharmony_ci#define S1_TCPFG        15
21788c2ecf20Sopenharmony_ci#define	S1_TCPHL	16
21798c2ecf20Sopenharmony_ci#define	S1_TCPHc	17
21808c2ecf20Sopenharmony_ci#define	S1_CLNP		18
21818c2ecf20Sopenharmony_ci#define	S1_CLNP2	19
21828c2ecf20Sopenharmony_ci#define	S1_DROP		20
21838c2ecf20Sopenharmony_ci#define	S2_HTTP		21
21848c2ecf20Sopenharmony_ci#define	S1_ESP4		22
21858c2ecf20Sopenharmony_ci#define	S1_AH4		23
21868c2ecf20Sopenharmony_ci#define	S1_ESP6		24
21878c2ecf20Sopenharmony_ci#define	S1_AH6		25
21888c2ecf20Sopenharmony_ci
21898c2ecf20Sopenharmony_ci#define CAS_PROG_IP46TCP4_PREAMBLE \
21908c2ecf20Sopenharmony_ci{ "packet arrival?", 0xffff, 0x0000, OP_NP,  6, S1_VLAN,  0, S1_PCKT,  \
21918c2ecf20Sopenharmony_ci  CL_REG, 0x3ff, 1, 0x0, 0x0000}, \
21928c2ecf20Sopenharmony_ci{ "VLAN?", 0xffff, 0x8100, OP_EQ,  1, S1_CFI,   0, S1_8023,  \
21938c2ecf20Sopenharmony_ci  IM_CTL, 0x00a,  3, 0x0, 0xffff}, \
21948c2ecf20Sopenharmony_ci{ "CFI?", 0x1000, 0x1000, OP_EQ,  0, S1_DROP,  1, S1_8023, \
21958c2ecf20Sopenharmony_ci  CL_REG, 0x000,  0, 0x0, 0x0000}, \
21968c2ecf20Sopenharmony_ci{ "8023?", 0xffff, 0x0600, OP_LT,  1, S1_LLC,   0, S1_IPV4, \
21978c2ecf20Sopenharmony_ci  CL_REG, 0x000,  0, 0x0, 0x0000}, \
21988c2ecf20Sopenharmony_ci{ "LLC?", 0xffff, 0xaaaa, OP_EQ,  1, S1_LLCc,  0, S1_CLNP, \
21998c2ecf20Sopenharmony_ci  CL_REG, 0x000,  0, 0x0, 0x0000}, \
22008c2ecf20Sopenharmony_ci{ "LLCc?", 0xff00, 0x0300, OP_EQ,  2, S1_IPV4,  0, S1_CLNP, \
22018c2ecf20Sopenharmony_ci  CL_REG, 0x000,  0, 0x0, 0x0000}, \
22028c2ecf20Sopenharmony_ci{ "IPV4?", 0xffff, 0x0800, OP_EQ,  1, S1_IPV4c, 0, S1_IPV6, \
22038c2ecf20Sopenharmony_ci  LD_SAP, 0x100,  3, 0x0, 0xffff}, \
22048c2ecf20Sopenharmony_ci{ "IPV4 cont?", 0xff00, 0x4500, OP_EQ,  3, S1_IPV4F, 0, S1_CLNP, \
22058c2ecf20Sopenharmony_ci  LD_SUM, 0x00a,  1, 0x0, 0x0000}, \
22068c2ecf20Sopenharmony_ci{ "IPV4 frag?", 0x3fff, 0x0000, OP_EQ,  1, S1_TCP44, 0, S1_CLNP, \
22078c2ecf20Sopenharmony_ci  LD_LEN, 0x03e,  1, 0x0, 0xffff}, \
22088c2ecf20Sopenharmony_ci{ "TCP44?", 0x00ff, 0x0006, OP_EQ,  7, S1_TCPSQ, 0, S1_CLNP, \
22098c2ecf20Sopenharmony_ci  LD_FID, 0x182,  1, 0x0, 0xffff}, /* FID IP4&TCP src+dst */ \
22108c2ecf20Sopenharmony_ci{ "IPV6?", 0xffff, 0x86dd, OP_EQ,  1, S1_IPV6L, 0, S1_CLNP,  \
22118c2ecf20Sopenharmony_ci  LD_SUM, 0x015,  1, 0x0, 0x0000}, \
22128c2ecf20Sopenharmony_ci{ "IPV6 len", 0xf000, 0x6000, OP_EQ,  0, S1_IPV6c, 0, S1_CLNP, \
22138c2ecf20Sopenharmony_ci  IM_R1,  0x128,  1, 0x0, 0xffff}, \
22148c2ecf20Sopenharmony_ci{ "IPV6 cont?", 0x0000, 0x0000, OP_EQ,  3, S1_TCP64, 0, S1_CLNP, \
22158c2ecf20Sopenharmony_ci  LD_FID, 0x484,  1, 0x0, 0xffff}, /* FID IP6&TCP src+dst */ \
22168c2ecf20Sopenharmony_ci{ "TCP64?", 0xff00, 0x0600, OP_EQ, 18, S1_TCPSQ, 0, S1_CLNP, \
22178c2ecf20Sopenharmony_ci  LD_LEN, 0x03f,  1, 0x0, 0xffff}
22188c2ecf20Sopenharmony_ci
22198c2ecf20Sopenharmony_ci#ifdef USE_HP_IP46TCP4
22208c2ecf20Sopenharmony_cistatic cas_hp_inst_t cas_prog_ip46tcp4tab[] = {
22218c2ecf20Sopenharmony_ci	CAS_PROG_IP46TCP4_PREAMBLE,
22228c2ecf20Sopenharmony_ci	{ "TCP seq", /* DADDR should point to dest port */
22238c2ecf20Sopenharmony_ci	  0x0000, 0x0000, OP_EQ, 0, S1_TCPFG, 4, S1_TCPFG, LD_SEQ,
22248c2ecf20Sopenharmony_ci	  0x081,  3, 0x0, 0xffff}, /* Load TCP seq # */
22258c2ecf20Sopenharmony_ci	{ "TCP control flags", 0x0000, 0x0000, OP_EQ,  0, S1_TCPHL, 0,
22268c2ecf20Sopenharmony_ci	  S1_TCPHL, ST_FLG, 0x045,  3, 0x0, 0x002f}, /* Load TCP flags */
22278c2ecf20Sopenharmony_ci	{ "TCP length", 0x0000, 0x0000, OP_EQ,  0, S1_TCPHc, 0,
22288c2ecf20Sopenharmony_ci	  S1_TCPHc, LD_R1,  0x205,  3, 0xB, 0xf000},
22298c2ecf20Sopenharmony_ci	{ "TCP length cont", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0,
22308c2ecf20Sopenharmony_ci	  S1_PCKT,  LD_HDR, 0x0ff,  3, 0x0, 0xffff},
22318c2ecf20Sopenharmony_ci	{ "Cleanup", 0x0000, 0x0000, OP_EQ,  0, S1_CLNP2,  0, S1_CLNP2,
22328c2ecf20Sopenharmony_ci	  IM_CTL, 0x001,  3, 0x0, 0x0001},
22338c2ecf20Sopenharmony_ci	{ "Cleanup 2", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0, S1_PCKT,
22348c2ecf20Sopenharmony_ci	  IM_CTL, 0x000,  0, 0x0, 0x0000},
22358c2ecf20Sopenharmony_ci	{ "Drop packet", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0, S1_PCKT,
22368c2ecf20Sopenharmony_ci	  IM_CTL, 0x080,  3, 0x0, 0xffff},
22378c2ecf20Sopenharmony_ci	{ NULL },
22388c2ecf20Sopenharmony_ci};
22398c2ecf20Sopenharmony_ci#ifdef HP_IP46TCP4_DEFAULT
22408c2ecf20Sopenharmony_ci#define CAS_HP_FIRMWARE               cas_prog_ip46tcp4tab
22418c2ecf20Sopenharmony_ci#endif
22428c2ecf20Sopenharmony_ci#endif
22438c2ecf20Sopenharmony_ci
22448c2ecf20Sopenharmony_ci/*
22458c2ecf20Sopenharmony_ci * Alternate table load which excludes HTTP server traffic from reassembly.
22468c2ecf20Sopenharmony_ci * It is substantially similar to the basic table, with one extra state
22478c2ecf20Sopenharmony_ci * and a few extra compares. */
22488c2ecf20Sopenharmony_ci#ifdef USE_HP_IP46TCP4NOHTTP
22498c2ecf20Sopenharmony_cistatic cas_hp_inst_t cas_prog_ip46tcp4nohttptab[] = {
22508c2ecf20Sopenharmony_ci	CAS_PROG_IP46TCP4_PREAMBLE,
22518c2ecf20Sopenharmony_ci	{ "TCP seq", /* DADDR should point to dest port */
22528c2ecf20Sopenharmony_ci	  0xFFFF, 0x0080, OP_EQ,  0, S2_HTTP,  0, S1_TCPFG, LD_SEQ,
22538c2ecf20Sopenharmony_ci	  0x081,  3, 0x0, 0xffff} , /* Load TCP seq # */
22548c2ecf20Sopenharmony_ci	{ "TCP control flags", 0xFFFF, 0x8080, OP_EQ,  0, S2_HTTP,  0,
22558c2ecf20Sopenharmony_ci	  S1_TCPHL, ST_FLG, 0x145,  2, 0x0, 0x002f, }, /* Load TCP flags */
22568c2ecf20Sopenharmony_ci	{ "TCP length", 0x0000, 0x0000, OP_EQ,  0, S1_TCPHc, 0, S1_TCPHc,
22578c2ecf20Sopenharmony_ci	  LD_R1,  0x205,  3, 0xB, 0xf000},
22588c2ecf20Sopenharmony_ci	{ "TCP length cont", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0, S1_PCKT,
22598c2ecf20Sopenharmony_ci	  LD_HDR, 0x0ff,  3, 0x0, 0xffff},
22608c2ecf20Sopenharmony_ci	{ "Cleanup", 0x0000, 0x0000, OP_EQ,  0, S1_CLNP2,  0, S1_CLNP2,
22618c2ecf20Sopenharmony_ci	  IM_CTL, 0x001,  3, 0x0, 0x0001},
22628c2ecf20Sopenharmony_ci	{ "Cleanup 2", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0, S1_PCKT,
22638c2ecf20Sopenharmony_ci	  CL_REG, 0x002,  3, 0x0, 0x0000},
22648c2ecf20Sopenharmony_ci	{ "Drop packet", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0, S1_PCKT,
22658c2ecf20Sopenharmony_ci	  IM_CTL, 0x080,  3, 0x0, 0xffff},
22668c2ecf20Sopenharmony_ci	{ "No HTTP", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0, S1_PCKT,
22678c2ecf20Sopenharmony_ci	  IM_CTL, 0x044,  3, 0x0, 0xffff},
22688c2ecf20Sopenharmony_ci	{ NULL },
22698c2ecf20Sopenharmony_ci};
22708c2ecf20Sopenharmony_ci#ifdef HP_IP46TCP4NOHTTP_DEFAULT
22718c2ecf20Sopenharmony_ci#define CAS_HP_FIRMWARE               cas_prog_ip46tcp4nohttptab
22728c2ecf20Sopenharmony_ci#endif
22738c2ecf20Sopenharmony_ci#endif
22748c2ecf20Sopenharmony_ci
22758c2ecf20Sopenharmony_ci/* match step #s for IP4FRAG */
22768c2ecf20Sopenharmony_ci#define	S3_IPV6c	11
22778c2ecf20Sopenharmony_ci#define	S3_TCP64	12
22788c2ecf20Sopenharmony_ci#define	S3_TCPSQ	13
22798c2ecf20Sopenharmony_ci#define	S3_TCPFG	14
22808c2ecf20Sopenharmony_ci#define	S3_TCPHL	15
22818c2ecf20Sopenharmony_ci#define	S3_TCPHc	16
22828c2ecf20Sopenharmony_ci#define	S3_FRAG		17
22838c2ecf20Sopenharmony_ci#define	S3_FOFF		18
22848c2ecf20Sopenharmony_ci#define	S3_CLNP		19
22858c2ecf20Sopenharmony_ci
22868c2ecf20Sopenharmony_ci#ifdef USE_HP_IP4FRAG
22878c2ecf20Sopenharmony_cistatic cas_hp_inst_t cas_prog_ip4fragtab[] = {
22888c2ecf20Sopenharmony_ci	{ "packet arrival?", 0xffff, 0x0000, OP_NP,  6, S1_VLAN,  0, S1_PCKT,
22898c2ecf20Sopenharmony_ci	  CL_REG, 0x3ff, 1, 0x0, 0x0000},
22908c2ecf20Sopenharmony_ci	{ "VLAN?", 0xffff, 0x8100, OP_EQ,  1, S1_CFI,   0, S1_8023,
22918c2ecf20Sopenharmony_ci	  IM_CTL, 0x00a,  3, 0x0, 0xffff},
22928c2ecf20Sopenharmony_ci	{ "CFI?", 0x1000, 0x1000, OP_EQ,  0, S3_CLNP,  1, S1_8023,
22938c2ecf20Sopenharmony_ci	  CL_REG, 0x000,  0, 0x0, 0x0000},
22948c2ecf20Sopenharmony_ci	{ "8023?", 0xffff, 0x0600, OP_LT,  1, S1_LLC,   0, S1_IPV4,
22958c2ecf20Sopenharmony_ci	  CL_REG, 0x000,  0, 0x0, 0x0000},
22968c2ecf20Sopenharmony_ci	{ "LLC?", 0xffff, 0xaaaa, OP_EQ,  1, S1_LLCc,  0, S3_CLNP,
22978c2ecf20Sopenharmony_ci	  CL_REG, 0x000,  0, 0x0, 0x0000},
22988c2ecf20Sopenharmony_ci	{ "LLCc?",0xff00, 0x0300, OP_EQ,  2, S1_IPV4,  0, S3_CLNP,
22998c2ecf20Sopenharmony_ci	  CL_REG, 0x000,  0, 0x0, 0x0000},
23008c2ecf20Sopenharmony_ci	{ "IPV4?", 0xffff, 0x0800, OP_EQ,  1, S1_IPV4c, 0, S1_IPV6,
23018c2ecf20Sopenharmony_ci	  LD_SAP, 0x100,  3, 0x0, 0xffff},
23028c2ecf20Sopenharmony_ci	{ "IPV4 cont?", 0xff00, 0x4500, OP_EQ,  3, S1_IPV4F, 0, S3_CLNP,
23038c2ecf20Sopenharmony_ci	  LD_SUM, 0x00a,  1, 0x0, 0x0000},
23048c2ecf20Sopenharmony_ci	{ "IPV4 frag?", 0x3fff, 0x0000, OP_EQ,  1, S1_TCP44, 0, S3_FRAG,
23058c2ecf20Sopenharmony_ci	  LD_LEN, 0x03e,  3, 0x0, 0xffff},
23068c2ecf20Sopenharmony_ci	{ "TCP44?", 0x00ff, 0x0006, OP_EQ,  7, S3_TCPSQ, 0, S3_CLNP,
23078c2ecf20Sopenharmony_ci	  LD_FID, 0x182,  3, 0x0, 0xffff}, /* FID IP4&TCP src+dst */
23088c2ecf20Sopenharmony_ci	{ "IPV6?", 0xffff, 0x86dd, OP_EQ,  1, S3_IPV6c, 0, S3_CLNP,
23098c2ecf20Sopenharmony_ci	  LD_SUM, 0x015,  1, 0x0, 0x0000},
23108c2ecf20Sopenharmony_ci	{ "IPV6 cont?", 0xf000, 0x6000, OP_EQ,  3, S3_TCP64, 0, S3_CLNP,
23118c2ecf20Sopenharmony_ci	  LD_FID, 0x484,  1, 0x0, 0xffff}, /* FID IP6&TCP src+dst */
23128c2ecf20Sopenharmony_ci	{ "TCP64?", 0xff00, 0x0600, OP_EQ, 18, S3_TCPSQ, 0, S3_CLNP,
23138c2ecf20Sopenharmony_ci	  LD_LEN, 0x03f,  1, 0x0, 0xffff},
23148c2ecf20Sopenharmony_ci	{ "TCP seq",	/* DADDR should point to dest port */
23158c2ecf20Sopenharmony_ci	  0x0000, 0x0000, OP_EQ,  0, S3_TCPFG, 4, S3_TCPFG, LD_SEQ,
23168c2ecf20Sopenharmony_ci	  0x081,  3, 0x0, 0xffff}, /* Load TCP seq # */
23178c2ecf20Sopenharmony_ci	{ "TCP control flags", 0x0000, 0x0000, OP_EQ,  0, S3_TCPHL, 0,
23188c2ecf20Sopenharmony_ci	  S3_TCPHL, ST_FLG, 0x045,  3, 0x0, 0x002f}, /* Load TCP flags */
23198c2ecf20Sopenharmony_ci	{ "TCP length", 0x0000, 0x0000, OP_EQ,  0, S3_TCPHc, 0, S3_TCPHc,
23208c2ecf20Sopenharmony_ci	  LD_R1,  0x205,  3, 0xB, 0xf000},
23218c2ecf20Sopenharmony_ci	{ "TCP length cont", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0, S1_PCKT,
23228c2ecf20Sopenharmony_ci	  LD_HDR, 0x0ff,  3, 0x0, 0xffff},
23238c2ecf20Sopenharmony_ci	{ "IP4 Fragment", 0x0000, 0x0000, OP_EQ,  0, S3_FOFF,  0, S3_FOFF,
23248c2ecf20Sopenharmony_ci	  LD_FID, 0x103,  3, 0x0, 0xffff}, /* FID IP4 src+dst */
23258c2ecf20Sopenharmony_ci	{ "IP4 frag offset", 0x0000, 0x0000, OP_EQ,  0, S3_FOFF,  0, S3_FOFF,
23268c2ecf20Sopenharmony_ci	  LD_SEQ, 0x040,  1, 0xD, 0xfff8},
23278c2ecf20Sopenharmony_ci	{ "Cleanup", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0, S1_PCKT,
23288c2ecf20Sopenharmony_ci	  IM_CTL, 0x001,  3, 0x0, 0x0001},
23298c2ecf20Sopenharmony_ci	{ NULL },
23308c2ecf20Sopenharmony_ci};
23318c2ecf20Sopenharmony_ci#ifdef HP_IP4FRAG_DEFAULT
23328c2ecf20Sopenharmony_ci#define CAS_HP_FIRMWARE               cas_prog_ip4fragtab
23338c2ecf20Sopenharmony_ci#endif
23348c2ecf20Sopenharmony_ci#endif
23358c2ecf20Sopenharmony_ci
23368c2ecf20Sopenharmony_ci/*
23378c2ecf20Sopenharmony_ci * Alternate table which does batching without reassembly
23388c2ecf20Sopenharmony_ci */
23398c2ecf20Sopenharmony_ci#ifdef USE_HP_IP46TCP4BATCH
23408c2ecf20Sopenharmony_cistatic cas_hp_inst_t cas_prog_ip46tcp4batchtab[] = {
23418c2ecf20Sopenharmony_ci	CAS_PROG_IP46TCP4_PREAMBLE,
23428c2ecf20Sopenharmony_ci	{ "TCP seq",	/* DADDR should point to dest port */
23438c2ecf20Sopenharmony_ci	  0x0000, 0x0000, OP_EQ,  0, S1_TCPFG, 0, S1_TCPFG, LD_SEQ,
23448c2ecf20Sopenharmony_ci	  0x081,  3, 0x0, 0xffff}, /* Load TCP seq # */
23458c2ecf20Sopenharmony_ci	{ "TCP control flags", 0x0000, 0x0000, OP_EQ,  0, S1_TCPHL, 0,
23468c2ecf20Sopenharmony_ci	  S1_TCPHL, ST_FLG, 0x000,  3, 0x0, 0x0000}, /* Load TCP flags */
23478c2ecf20Sopenharmony_ci	{ "TCP length", 0x0000, 0x0000, OP_EQ,  0, S1_TCPHc, 0,
23488c2ecf20Sopenharmony_ci	  S1_TCPHc, LD_R1,  0x205,  3, 0xB, 0xf000},
23498c2ecf20Sopenharmony_ci	{ "TCP length cont", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0,
23508c2ecf20Sopenharmony_ci	  S1_PCKT,  IM_CTL, 0x040,  3, 0x0, 0xffff}, /* set batch bit */
23518c2ecf20Sopenharmony_ci	{ "Cleanup", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0, S1_PCKT,
23528c2ecf20Sopenharmony_ci	  IM_CTL, 0x001,  3, 0x0, 0x0001},
23538c2ecf20Sopenharmony_ci	{ "Drop packet", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0,
23548c2ecf20Sopenharmony_ci	  S1_PCKT,  IM_CTL, 0x080,  3, 0x0, 0xffff},
23558c2ecf20Sopenharmony_ci	{ NULL },
23568c2ecf20Sopenharmony_ci};
23578c2ecf20Sopenharmony_ci#ifdef HP_IP46TCP4BATCH_DEFAULT
23588c2ecf20Sopenharmony_ci#define CAS_HP_FIRMWARE               cas_prog_ip46tcp4batchtab
23598c2ecf20Sopenharmony_ci#endif
23608c2ecf20Sopenharmony_ci#endif
23618c2ecf20Sopenharmony_ci
23628c2ecf20Sopenharmony_ci/* Workaround for Cassini rev2 descriptor corruption problem.
23638c2ecf20Sopenharmony_ci * Does batching without reassembly, and sets the SAP to a known
23648c2ecf20Sopenharmony_ci * data pattern for all packets.
23658c2ecf20Sopenharmony_ci */
23668c2ecf20Sopenharmony_ci#ifdef USE_HP_WORKAROUND
23678c2ecf20Sopenharmony_cistatic cas_hp_inst_t  cas_prog_workaroundtab[] = {
23688c2ecf20Sopenharmony_ci	{ "packet arrival?", 0xffff, 0x0000, OP_NP,  6, S1_VLAN,  0,
23698c2ecf20Sopenharmony_ci	  S1_PCKT,  CL_REG, 0x3ff,  1, 0x0, 0x0000} ,
23708c2ecf20Sopenharmony_ci	{ "VLAN?", 0xffff, 0x8100, OP_EQ,  1, S1_CFI, 0, S1_8023,
23718c2ecf20Sopenharmony_ci	  IM_CTL, 0x04a,  3, 0x0, 0xffff},
23728c2ecf20Sopenharmony_ci	{ "CFI?", 0x1000, 0x1000, OP_EQ,  0, S1_CLNP,  1, S1_8023,
23738c2ecf20Sopenharmony_ci	  CL_REG, 0x000,  0, 0x0, 0x0000},
23748c2ecf20Sopenharmony_ci	{ "8023?", 0xffff, 0x0600, OP_LT,  1, S1_LLC,   0, S1_IPV4,
23758c2ecf20Sopenharmony_ci	  CL_REG, 0x000,  0, 0x0, 0x0000},
23768c2ecf20Sopenharmony_ci	{ "LLC?", 0xffff, 0xaaaa, OP_EQ,  1, S1_LLCc,  0, S1_CLNP,
23778c2ecf20Sopenharmony_ci	  CL_REG, 0x000,  0, 0x0, 0x0000},
23788c2ecf20Sopenharmony_ci	{ "LLCc?", 0xff00, 0x0300, OP_EQ,  2, S1_IPV4,  0, S1_CLNP,
23798c2ecf20Sopenharmony_ci	  CL_REG, 0x000,  0, 0x0, 0x0000},
23808c2ecf20Sopenharmony_ci	{ "IPV4?", 0xffff, 0x0800, OP_EQ,  1, S1_IPV4c, 0, S1_IPV6,
23818c2ecf20Sopenharmony_ci	  IM_SAP, 0x6AE,  3, 0x0, 0xffff},
23828c2ecf20Sopenharmony_ci	{ "IPV4 cont?", 0xff00, 0x4500, OP_EQ,  3, S1_IPV4F, 0, S1_CLNP,
23838c2ecf20Sopenharmony_ci	  LD_SUM, 0x00a,  1, 0x0, 0x0000},
23848c2ecf20Sopenharmony_ci	{ "IPV4 frag?", 0x3fff, 0x0000, OP_EQ,  1, S1_TCP44, 0, S1_CLNP,
23858c2ecf20Sopenharmony_ci	  LD_LEN, 0x03e,  1, 0x0, 0xffff},
23868c2ecf20Sopenharmony_ci	{ "TCP44?", 0x00ff, 0x0006, OP_EQ,  7, S1_TCPSQ, 0, S1_CLNP,
23878c2ecf20Sopenharmony_ci	  LD_FID, 0x182,  3, 0x0, 0xffff}, /* FID IP4&TCP src+dst */
23888c2ecf20Sopenharmony_ci	{ "IPV6?", 0xffff, 0x86dd, OP_EQ,  1, S1_IPV6L, 0, S1_CLNP,
23898c2ecf20Sopenharmony_ci	  LD_SUM, 0x015,  1, 0x0, 0x0000},
23908c2ecf20Sopenharmony_ci	{ "IPV6 len", 0xf000, 0x6000, OP_EQ,  0, S1_IPV6c, 0, S1_CLNP,
23918c2ecf20Sopenharmony_ci	  IM_R1,  0x128,  1, 0x0, 0xffff},
23928c2ecf20Sopenharmony_ci	{ "IPV6 cont?", 0x0000, 0x0000, OP_EQ,  3, S1_TCP64, 0, S1_CLNP,
23938c2ecf20Sopenharmony_ci	  LD_FID, 0x484,  1, 0x0, 0xffff}, /* FID IP6&TCP src+dst */
23948c2ecf20Sopenharmony_ci	{ "TCP64?", 0xff00, 0x0600, OP_EQ, 18, S1_TCPSQ, 0, S1_CLNP,
23958c2ecf20Sopenharmony_ci	  LD_LEN, 0x03f,  1, 0x0, 0xffff},
23968c2ecf20Sopenharmony_ci	{ "TCP seq",      /* DADDR should point to dest port */
23978c2ecf20Sopenharmony_ci	  0x0000, 0x0000, OP_EQ,  0, S1_TCPFG, 4, S1_TCPFG, LD_SEQ,
23988c2ecf20Sopenharmony_ci	  0x081,  3, 0x0, 0xffff}, /* Load TCP seq # */
23998c2ecf20Sopenharmony_ci	{ "TCP control flags", 0x0000, 0x0000, OP_EQ,  0, S1_TCPHL, 0,
24008c2ecf20Sopenharmony_ci	  S1_TCPHL, ST_FLG, 0x045,  3, 0x0, 0x002f}, /* Load TCP flags */
24018c2ecf20Sopenharmony_ci	{ "TCP length", 0x0000, 0x0000, OP_EQ,  0, S1_TCPHc, 0, S1_TCPHc,
24028c2ecf20Sopenharmony_ci	  LD_R1,  0x205,  3, 0xB, 0xf000},
24038c2ecf20Sopenharmony_ci	{ "TCP length cont", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0,
24048c2ecf20Sopenharmony_ci	  S1_PCKT,  LD_HDR, 0x0ff,  3, 0x0, 0xffff},
24058c2ecf20Sopenharmony_ci	{ "Cleanup", 0x0000, 0x0000, OP_EQ,  0, S1_CLNP2, 0, S1_CLNP2,
24068c2ecf20Sopenharmony_ci	  IM_SAP, 0x6AE,  3, 0x0, 0xffff} ,
24078c2ecf20Sopenharmony_ci	{ "Cleanup 2", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0, S1_PCKT,
24088c2ecf20Sopenharmony_ci	  IM_CTL, 0x001,  3, 0x0, 0x0001},
24098c2ecf20Sopenharmony_ci	{ NULL },
24108c2ecf20Sopenharmony_ci};
24118c2ecf20Sopenharmony_ci#ifdef HP_WORKAROUND_DEFAULT
24128c2ecf20Sopenharmony_ci#define CAS_HP_FIRMWARE               cas_prog_workaroundtab
24138c2ecf20Sopenharmony_ci#endif
24148c2ecf20Sopenharmony_ci#endif
24158c2ecf20Sopenharmony_ci
24168c2ecf20Sopenharmony_ci#ifdef USE_HP_ENCRYPT
24178c2ecf20Sopenharmony_cistatic cas_hp_inst_t  cas_prog_encryptiontab[] = {
24188c2ecf20Sopenharmony_ci	{ "packet arrival?", 0xffff, 0x0000, OP_NP,  6, S1_VLAN,  0,
24198c2ecf20Sopenharmony_ci	  S1_PCKT,  CL_REG, 0x3ff,  1, 0x0, 0x0000},
24208c2ecf20Sopenharmony_ci	{ "VLAN?", 0xffff, 0x8100, OP_EQ,  1, S1_CFI,   0, S1_8023,
24218c2ecf20Sopenharmony_ci	  IM_CTL, 0x00a,  3, 0x0, 0xffff},
24228c2ecf20Sopenharmony_ci#if 0
24238c2ecf20Sopenharmony_ci//"CFI?", /* 02 FIND CFI and If FIND go to S1_DROP */
24248c2ecf20Sopenharmony_ci//0x1000, 0x1000, OP_EQ,  0, S1_DROP,  1, S1_8023,  CL_REG, 0x000,  0, 0x0, 0x00
24258c2ecf20Sopenharmony_ci	00,
24268c2ecf20Sopenharmony_ci#endif
24278c2ecf20Sopenharmony_ci	{ "CFI?", /* FIND CFI and If FIND go to CleanUP1 (ignore and send to host) */
24288c2ecf20Sopenharmony_ci	  0x1000, 0x1000, OP_EQ,  0, S1_CLNP,  1, S1_8023,
24298c2ecf20Sopenharmony_ci	  CL_REG, 0x000,  0, 0x0, 0x0000},
24308c2ecf20Sopenharmony_ci	{ "8023?", 0xffff, 0x0600, OP_LT,  1, S1_LLC,   0, S1_IPV4,
24318c2ecf20Sopenharmony_ci	  CL_REG, 0x000,  0, 0x0, 0x0000},
24328c2ecf20Sopenharmony_ci	{ "LLC?", 0xffff, 0xaaaa, OP_EQ,  1, S1_LLCc,  0, S1_CLNP,
24338c2ecf20Sopenharmony_ci	  CL_REG, 0x000,  0, 0x0, 0x0000},
24348c2ecf20Sopenharmony_ci	{ "LLCc?", 0xff00, 0x0300, OP_EQ,  2, S1_IPV4,  0, S1_CLNP,
24358c2ecf20Sopenharmony_ci	  CL_REG, 0x000,  0, 0x0, 0x0000},
24368c2ecf20Sopenharmony_ci	{ "IPV4?", 0xffff, 0x0800, OP_EQ,  1, S1_IPV4c, 0, S1_IPV6,
24378c2ecf20Sopenharmony_ci	  LD_SAP, 0x100,  3, 0x0, 0xffff},
24388c2ecf20Sopenharmony_ci	{ "IPV4 cont?", 0xff00, 0x4500, OP_EQ,  3, S1_IPV4F, 0, S1_CLNP,
24398c2ecf20Sopenharmony_ci	  LD_SUM, 0x00a,  1, 0x0, 0x0000},
24408c2ecf20Sopenharmony_ci	{ "IPV4 frag?", 0x3fff, 0x0000, OP_EQ,  1, S1_TCP44, 0, S1_CLNP,
24418c2ecf20Sopenharmony_ci	  LD_LEN, 0x03e,  1, 0x0, 0xffff},
24428c2ecf20Sopenharmony_ci	{ "TCP44?", 0x00ff, 0x0006, OP_EQ,  7, S1_TCPSQ, 0, S1_ESP4,
24438c2ecf20Sopenharmony_ci	  LD_FID, 0x182,  1, 0x0, 0xffff}, /* FID IP4&TCP src+dst */
24448c2ecf20Sopenharmony_ci	{ "IPV6?", 0xffff, 0x86dd, OP_EQ,  1, S1_IPV6L, 0, S1_CLNP,
24458c2ecf20Sopenharmony_ci	  LD_SUM, 0x015,  1, 0x0, 0x0000},
24468c2ecf20Sopenharmony_ci	{ "IPV6 len", 0xf000, 0x6000, OP_EQ,  0, S1_IPV6c, 0, S1_CLNP,
24478c2ecf20Sopenharmony_ci	  IM_R1,  0x128,  1, 0x0, 0xffff},
24488c2ecf20Sopenharmony_ci	{ "IPV6 cont?", 0x0000, 0x0000, OP_EQ,  3, S1_TCP64, 0, S1_CLNP,
24498c2ecf20Sopenharmony_ci	  LD_FID, 0x484,  1, 0x0, 0xffff}, /*  FID IP6&TCP src+dst */
24508c2ecf20Sopenharmony_ci	{ "TCP64?",
24518c2ecf20Sopenharmony_ci#if 0
24528c2ecf20Sopenharmony_ci//@@@0xff00, 0x0600, OP_EQ, 18, S1_TCPSQ, 0, S1_ESP6,  LD_LEN, 0x03f,  1, 0x0, 0xffff,
24538c2ecf20Sopenharmony_ci#endif
24548c2ecf20Sopenharmony_ci	  0xff00, 0x0600, OP_EQ, 12, S1_TCPSQ, 0, S1_ESP6,  LD_LEN,
24558c2ecf20Sopenharmony_ci	  0x03f,  1, 0x0, 0xffff},
24568c2ecf20Sopenharmony_ci	{ "TCP seq", /* 14:DADDR should point to dest port */
24578c2ecf20Sopenharmony_ci	  0xFFFF, 0x0080, OP_EQ,  0, S2_HTTP,  0, S1_TCPFG, LD_SEQ,
24588c2ecf20Sopenharmony_ci	  0x081,  3, 0x0, 0xffff}, /* Load TCP seq # */
24598c2ecf20Sopenharmony_ci	{ "TCP control flags", 0xFFFF, 0x8080, OP_EQ,  0, S2_HTTP,  0,
24608c2ecf20Sopenharmony_ci	  S1_TCPHL, ST_FLG, 0x145,  2, 0x0, 0x002f}, /* Load TCP flags */
24618c2ecf20Sopenharmony_ci	{ "TCP length", 0x0000, 0x0000, OP_EQ,  0, S1_TCPHc, 0, S1_TCPHc,
24628c2ecf20Sopenharmony_ci	  LD_R1,  0x205,  3, 0xB, 0xf000} ,
24638c2ecf20Sopenharmony_ci	{ "TCP length cont", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0,
24648c2ecf20Sopenharmony_ci	  S1_PCKT,  LD_HDR, 0x0ff,  3, 0x0, 0xffff},
24658c2ecf20Sopenharmony_ci	{ "Cleanup", 0x0000, 0x0000, OP_EQ,  0, S1_CLNP2,  0, S1_CLNP2,
24668c2ecf20Sopenharmony_ci	  IM_CTL, 0x001,  3, 0x0, 0x0001},
24678c2ecf20Sopenharmony_ci	{ "Cleanup 2", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0, S1_PCKT,
24688c2ecf20Sopenharmony_ci	  CL_REG, 0x002,  3, 0x0, 0x0000},
24698c2ecf20Sopenharmony_ci	{ "Drop packet", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0, S1_PCKT,
24708c2ecf20Sopenharmony_ci	  IM_CTL, 0x080,  3, 0x0, 0xffff},
24718c2ecf20Sopenharmony_ci	{ "No HTTP", 0x0000, 0x0000, OP_EQ,  0, S1_PCKT,  0, S1_PCKT,
24728c2ecf20Sopenharmony_ci	  IM_CTL, 0x044,  3, 0x0, 0xffff},
24738c2ecf20Sopenharmony_ci	{ "IPV4 ESP encrypted?",  /* S1_ESP4 */
24748c2ecf20Sopenharmony_ci	  0x00ff, 0x0032, OP_EQ,  0, S1_CLNP2, 0, S1_AH4, IM_CTL,
24758c2ecf20Sopenharmony_ci	  0x021, 1,  0x0, 0xffff},
24768c2ecf20Sopenharmony_ci	{ "IPV4 AH encrypted?",   /* S1_AH4 */
24778c2ecf20Sopenharmony_ci	  0x00ff, 0x0033, OP_EQ,  0, S1_CLNP2, 0, S1_CLNP, IM_CTL,
24788c2ecf20Sopenharmony_ci	  0x021, 1,  0x0, 0xffff},
24798c2ecf20Sopenharmony_ci	{ "IPV6 ESP encrypted?",  /* S1_ESP6 */
24808c2ecf20Sopenharmony_ci#if 0
24818c2ecf20Sopenharmony_ci//@@@0x00ff, 0x0032, OP_EQ,  0, S1_CLNP2, 0, S1_AH6, IM_CTL, 0x021, 1,  0x0, 0xffff,
24828c2ecf20Sopenharmony_ci#endif
24838c2ecf20Sopenharmony_ci	  0xff00, 0x3200, OP_EQ,  0, S1_CLNP2, 0, S1_AH6, IM_CTL,
24848c2ecf20Sopenharmony_ci	  0x021, 1,  0x0, 0xffff},
24858c2ecf20Sopenharmony_ci	{ "IPV6 AH encrypted?",   /* S1_AH6 */
24868c2ecf20Sopenharmony_ci#if 0
24878c2ecf20Sopenharmony_ci//@@@0x00ff, 0x0033, OP_EQ,  0, S1_CLNP2, 0, S1_CLNP, IM_CTL, 0x021, 1,  0x0, 0xffff,
24888c2ecf20Sopenharmony_ci#endif
24898c2ecf20Sopenharmony_ci	  0xff00, 0x3300, OP_EQ,  0, S1_CLNP2, 0, S1_CLNP, IM_CTL,
24908c2ecf20Sopenharmony_ci	  0x021, 1,  0x0, 0xffff},
24918c2ecf20Sopenharmony_ci	{ NULL },
24928c2ecf20Sopenharmony_ci};
24938c2ecf20Sopenharmony_ci#ifdef HP_ENCRYPT_DEFAULT
24948c2ecf20Sopenharmony_ci#define CAS_HP_FIRMWARE               cas_prog_encryptiontab
24958c2ecf20Sopenharmony_ci#endif
24968c2ecf20Sopenharmony_ci#endif
24978c2ecf20Sopenharmony_ci
24988c2ecf20Sopenharmony_cistatic cas_hp_inst_t cas_prog_null[] = { {NULL} };
24998c2ecf20Sopenharmony_ci#ifdef HP_NULL_DEFAULT
25008c2ecf20Sopenharmony_ci#define CAS_HP_FIRMWARE               cas_prog_null
25018c2ecf20Sopenharmony_ci#endif
25028c2ecf20Sopenharmony_ci
25038c2ecf20Sopenharmony_ci/* phy types */
25048c2ecf20Sopenharmony_ci#define   CAS_PHY_UNKNOWN       0x00
25058c2ecf20Sopenharmony_ci#define   CAS_PHY_SERDES        0x01
25068c2ecf20Sopenharmony_ci#define   CAS_PHY_MII_MDIO0     0x02
25078c2ecf20Sopenharmony_ci#define   CAS_PHY_MII_MDIO1     0x04
25088c2ecf20Sopenharmony_ci#define   CAS_PHY_MII(x)        ((x) & (CAS_PHY_MII_MDIO0 | CAS_PHY_MII_MDIO1))
25098c2ecf20Sopenharmony_ci
25108c2ecf20Sopenharmony_ci/* _RING_INDEX is the index for the ring sizes to be used.  _RING_SIZE
25118c2ecf20Sopenharmony_ci * is the actual size. the default index for the various rings is
25128c2ecf20Sopenharmony_ci * 8. NOTE: there a bunch of alignment constraints for the rings. to
25138c2ecf20Sopenharmony_ci * deal with that, i just allocate rings to create the desired
25148c2ecf20Sopenharmony_ci * alignment. here are the constraints:
25158c2ecf20Sopenharmony_ci *   RX DESC and COMP rings must be 8KB aligned
25168c2ecf20Sopenharmony_ci *   TX DESC must be 2KB aligned.
25178c2ecf20Sopenharmony_ci * if you change the numbers, be cognizant of how the alignment will change
25188c2ecf20Sopenharmony_ci * in INIT_BLOCK as well.
25198c2ecf20Sopenharmony_ci */
25208c2ecf20Sopenharmony_ci
25218c2ecf20Sopenharmony_ci#define DESC_RING_I_TO_S(x)  (32*(1 << (x)))
25228c2ecf20Sopenharmony_ci#define COMP_RING_I_TO_S(x)  (128*(1 << (x)))
25238c2ecf20Sopenharmony_ci#define TX_DESC_RING_INDEX 4  /* 512 = 8k */
25248c2ecf20Sopenharmony_ci#define RX_DESC_RING_INDEX 4  /* 512 = 8k */
25258c2ecf20Sopenharmony_ci#define RX_COMP_RING_INDEX 4  /* 2048 = 64k: should be 4x rx ring size */
25268c2ecf20Sopenharmony_ci
25278c2ecf20Sopenharmony_ci#if (TX_DESC_RING_INDEX > 8) || (TX_DESC_RING_INDEX < 0)
25288c2ecf20Sopenharmony_ci#error TX_DESC_RING_INDEX must be between 0 and 8
25298c2ecf20Sopenharmony_ci#endif
25308c2ecf20Sopenharmony_ci
25318c2ecf20Sopenharmony_ci#if (RX_DESC_RING_INDEX > 8) || (RX_DESC_RING_INDEX < 0)
25328c2ecf20Sopenharmony_ci#error RX_DESC_RING_INDEX must be between 0 and 8
25338c2ecf20Sopenharmony_ci#endif
25348c2ecf20Sopenharmony_ci
25358c2ecf20Sopenharmony_ci#if (RX_COMP_RING_INDEX > 8) || (RX_COMP_RING_INDEX < 0)
25368c2ecf20Sopenharmony_ci#error RX_COMP_RING_INDEX must be between 0 and 8
25378c2ecf20Sopenharmony_ci#endif
25388c2ecf20Sopenharmony_ci
25398c2ecf20Sopenharmony_ci#define N_TX_RINGS                    MAX_TX_RINGS      /* for QoS */
25408c2ecf20Sopenharmony_ci#define N_TX_RINGS_MASK               MAX_TX_RINGS_MASK
25418c2ecf20Sopenharmony_ci#define N_RX_DESC_RINGS               MAX_RX_DESC_RINGS /* 1 for ipsec */
25428c2ecf20Sopenharmony_ci#define N_RX_COMP_RINGS               0x1 /* for mult. PCI interrupts */
25438c2ecf20Sopenharmony_ci
25448c2ecf20Sopenharmony_ci/* number of flows that can go through re-assembly */
25458c2ecf20Sopenharmony_ci#define N_RX_FLOWS                    64
25468c2ecf20Sopenharmony_ci
25478c2ecf20Sopenharmony_ci#define TX_DESC_RING_SIZE  DESC_RING_I_TO_S(TX_DESC_RING_INDEX)
25488c2ecf20Sopenharmony_ci#define RX_DESC_RING_SIZE  DESC_RING_I_TO_S(RX_DESC_RING_INDEX)
25498c2ecf20Sopenharmony_ci#define RX_COMP_RING_SIZE  COMP_RING_I_TO_S(RX_COMP_RING_INDEX)
25508c2ecf20Sopenharmony_ci#define TX_DESC_RINGN_INDEX(x) TX_DESC_RING_INDEX
25518c2ecf20Sopenharmony_ci#define RX_DESC_RINGN_INDEX(x) RX_DESC_RING_INDEX
25528c2ecf20Sopenharmony_ci#define RX_COMP_RINGN_INDEX(x) RX_COMP_RING_INDEX
25538c2ecf20Sopenharmony_ci#define TX_DESC_RINGN_SIZE(x)  TX_DESC_RING_SIZE
25548c2ecf20Sopenharmony_ci#define RX_DESC_RINGN_SIZE(x)  RX_DESC_RING_SIZE
25558c2ecf20Sopenharmony_ci#define RX_COMP_RINGN_SIZE(x)  RX_COMP_RING_SIZE
25568c2ecf20Sopenharmony_ci
25578c2ecf20Sopenharmony_ci/* convert values */
25588c2ecf20Sopenharmony_ci#define CAS_BASE(x, y)                (((y) << (x ## _SHIFT)) & (x ## _MASK))
25598c2ecf20Sopenharmony_ci#define CAS_VAL(x, y)                 (((y) & (x ## _MASK)) >> (x ## _SHIFT))
25608c2ecf20Sopenharmony_ci#define CAS_TX_RINGN_BASE(y)          ((TX_DESC_RINGN_INDEX(y) << \
25618c2ecf20Sopenharmony_ci                                        TX_CFG_DESC_RINGN_SHIFT(y)) & \
25628c2ecf20Sopenharmony_ci                                        TX_CFG_DESC_RINGN_MASK(y))
25638c2ecf20Sopenharmony_ci
25648c2ecf20Sopenharmony_ci/* min is 2k, but we can't do jumbo frames unless it's at least 8k */
25658c2ecf20Sopenharmony_ci#define CAS_MIN_PAGE_SHIFT            11 /* 2048 */
25668c2ecf20Sopenharmony_ci#define CAS_JUMBO_PAGE_SHIFT          13 /* 8192 */
25678c2ecf20Sopenharmony_ci#define CAS_MAX_PAGE_SHIFT            14 /* 16384 */
25688c2ecf20Sopenharmony_ci
25698c2ecf20Sopenharmony_ci#define TX_DESC_BUFLEN_MASK         0x0000000000003FFFULL /* buffer length in
25708c2ecf20Sopenharmony_ci							     bytes. 0 - 9256 */
25718c2ecf20Sopenharmony_ci#define TX_DESC_BUFLEN_SHIFT        0
25728c2ecf20Sopenharmony_ci#define TX_DESC_CSUM_START_MASK     0x00000000001F8000ULL /* checksum start. #
25738c2ecf20Sopenharmony_ci							     of bytes to be
25748c2ecf20Sopenharmony_ci							     skipped before
25758c2ecf20Sopenharmony_ci							     csum calc begins.
25768c2ecf20Sopenharmony_ci							     value must be
25778c2ecf20Sopenharmony_ci							     even */
25788c2ecf20Sopenharmony_ci#define TX_DESC_CSUM_START_SHIFT    15
25798c2ecf20Sopenharmony_ci#define TX_DESC_CSUM_STUFF_MASK     0x000000001FE00000ULL /* checksum stuff.
25808c2ecf20Sopenharmony_ci							     byte offset w/in
25818c2ecf20Sopenharmony_ci							     the pkt for the
25828c2ecf20Sopenharmony_ci							     1st csum byte.
25838c2ecf20Sopenharmony_ci							     must be > 8 */
25848c2ecf20Sopenharmony_ci#define TX_DESC_CSUM_STUFF_SHIFT    21
25858c2ecf20Sopenharmony_ci#define TX_DESC_CSUM_EN             0x0000000020000000ULL /* enable checksum */
25868c2ecf20Sopenharmony_ci#define TX_DESC_EOF                 0x0000000040000000ULL /* end of frame */
25878c2ecf20Sopenharmony_ci#define TX_DESC_SOF                 0x0000000080000000ULL /* start of frame */
25888c2ecf20Sopenharmony_ci#define TX_DESC_INTME               0x0000000100000000ULL /* interrupt me */
25898c2ecf20Sopenharmony_ci#define TX_DESC_NO_CRC              0x0000000200000000ULL /* debugging only.
25908c2ecf20Sopenharmony_ci							     CRC will not be
25918c2ecf20Sopenharmony_ci							     inserted into
25928c2ecf20Sopenharmony_ci							     outgoing frame. */
25938c2ecf20Sopenharmony_cistruct cas_tx_desc {
25948c2ecf20Sopenharmony_ci	__le64     control;
25958c2ecf20Sopenharmony_ci	__le64     buffer;
25968c2ecf20Sopenharmony_ci};
25978c2ecf20Sopenharmony_ci
25988c2ecf20Sopenharmony_ci/* descriptor ring for free buffers contains page-sized buffers. the index
25998c2ecf20Sopenharmony_ci * value is not used by the hw in any way. it's just stored and returned in
26008c2ecf20Sopenharmony_ci * the completion ring.
26018c2ecf20Sopenharmony_ci */
26028c2ecf20Sopenharmony_cistruct cas_rx_desc {
26038c2ecf20Sopenharmony_ci	__le64     index;
26048c2ecf20Sopenharmony_ci	__le64     buffer;
26058c2ecf20Sopenharmony_ci};
26068c2ecf20Sopenharmony_ci
26078c2ecf20Sopenharmony_ci/* received packets are put on the completion ring. */
26088c2ecf20Sopenharmony_ci/* word 1 */
26098c2ecf20Sopenharmony_ci#define RX_COMP1_DATA_SIZE_MASK           0x0000000007FFE000ULL
26108c2ecf20Sopenharmony_ci#define RX_COMP1_DATA_SIZE_SHIFT          13
26118c2ecf20Sopenharmony_ci#define RX_COMP1_DATA_OFF_MASK            0x000001FFF8000000ULL
26128c2ecf20Sopenharmony_ci#define RX_COMP1_DATA_OFF_SHIFT           27
26138c2ecf20Sopenharmony_ci#define RX_COMP1_DATA_INDEX_MASK          0x007FFE0000000000ULL
26148c2ecf20Sopenharmony_ci#define RX_COMP1_DATA_INDEX_SHIFT         41
26158c2ecf20Sopenharmony_ci#define RX_COMP1_SKIP_MASK                0x0180000000000000ULL
26168c2ecf20Sopenharmony_ci#define RX_COMP1_SKIP_SHIFT               55
26178c2ecf20Sopenharmony_ci#define RX_COMP1_RELEASE_NEXT             0x0200000000000000ULL
26188c2ecf20Sopenharmony_ci#define RX_COMP1_SPLIT_PKT                0x0400000000000000ULL
26198c2ecf20Sopenharmony_ci#define RX_COMP1_RELEASE_FLOW             0x0800000000000000ULL
26208c2ecf20Sopenharmony_ci#define RX_COMP1_RELEASE_DATA             0x1000000000000000ULL
26218c2ecf20Sopenharmony_ci#define RX_COMP1_RELEASE_HDR              0x2000000000000000ULL
26228c2ecf20Sopenharmony_ci#define RX_COMP1_TYPE_MASK                0xC000000000000000ULL
26238c2ecf20Sopenharmony_ci#define RX_COMP1_TYPE_SHIFT               62
26248c2ecf20Sopenharmony_ci
26258c2ecf20Sopenharmony_ci/* word 2 */
26268c2ecf20Sopenharmony_ci#define RX_COMP2_NEXT_INDEX_MASK          0x00000007FFE00000ULL
26278c2ecf20Sopenharmony_ci#define RX_COMP2_NEXT_INDEX_SHIFT         21
26288c2ecf20Sopenharmony_ci#define RX_COMP2_HDR_SIZE_MASK            0x00000FF800000000ULL
26298c2ecf20Sopenharmony_ci#define RX_COMP2_HDR_SIZE_SHIFT           35
26308c2ecf20Sopenharmony_ci#define RX_COMP2_HDR_OFF_MASK             0x0003F00000000000ULL
26318c2ecf20Sopenharmony_ci#define RX_COMP2_HDR_OFF_SHIFT            44
26328c2ecf20Sopenharmony_ci#define RX_COMP2_HDR_INDEX_MASK           0xFFFC000000000000ULL
26338c2ecf20Sopenharmony_ci#define RX_COMP2_HDR_INDEX_SHIFT          50
26348c2ecf20Sopenharmony_ci
26358c2ecf20Sopenharmony_ci/* word 3 */
26368c2ecf20Sopenharmony_ci#define RX_COMP3_SMALL_PKT                0x0000000000000001ULL
26378c2ecf20Sopenharmony_ci#define RX_COMP3_JUMBO_PKT                0x0000000000000002ULL
26388c2ecf20Sopenharmony_ci#define RX_COMP3_JUMBO_HDR_SPLIT_EN       0x0000000000000004ULL
26398c2ecf20Sopenharmony_ci#define RX_COMP3_CSUM_START_MASK          0x000000000007F000ULL
26408c2ecf20Sopenharmony_ci#define RX_COMP3_CSUM_START_SHIFT         12
26418c2ecf20Sopenharmony_ci#define RX_COMP3_FLOWID_MASK              0x0000000001F80000ULL
26428c2ecf20Sopenharmony_ci#define RX_COMP3_FLOWID_SHIFT             19
26438c2ecf20Sopenharmony_ci#define RX_COMP3_OPCODE_MASK              0x000000000E000000ULL
26448c2ecf20Sopenharmony_ci#define RX_COMP3_OPCODE_SHIFT             25
26458c2ecf20Sopenharmony_ci#define RX_COMP3_FORCE_FLAG               0x0000000010000000ULL
26468c2ecf20Sopenharmony_ci#define RX_COMP3_NO_ASSIST                0x0000000020000000ULL
26478c2ecf20Sopenharmony_ci#define RX_COMP3_LOAD_BAL_MASK            0x000001F800000000ULL
26488c2ecf20Sopenharmony_ci#define RX_COMP3_LOAD_BAL_SHIFT           35
26498c2ecf20Sopenharmony_ci#define RX_PLUS_COMP3_ENC_PKT             0x0000020000000000ULL /* cas+ */
26508c2ecf20Sopenharmony_ci#define RX_COMP3_L3_HEAD_OFF_MASK         0x0000FE0000000000ULL /* cas */
26518c2ecf20Sopenharmony_ci#define RX_COMP3_L3_HEAD_OFF_SHIFT        41
26528c2ecf20Sopenharmony_ci#define RX_PLUS_COMP_L3_HEAD_OFF_MASK     0x0000FC0000000000ULL /* cas+ */
26538c2ecf20Sopenharmony_ci#define RX_PLUS_COMP_L3_HEAD_OFF_SHIFT    42
26548c2ecf20Sopenharmony_ci#define RX_COMP3_SAP_MASK                 0xFFFF000000000000ULL
26558c2ecf20Sopenharmony_ci#define RX_COMP3_SAP_SHIFT                48
26568c2ecf20Sopenharmony_ci
26578c2ecf20Sopenharmony_ci/* word 4 */
26588c2ecf20Sopenharmony_ci#define RX_COMP4_TCP_CSUM_MASK            0x000000000000FFFFULL
26598c2ecf20Sopenharmony_ci#define RX_COMP4_TCP_CSUM_SHIFT           0
26608c2ecf20Sopenharmony_ci#define RX_COMP4_PKT_LEN_MASK             0x000000003FFF0000ULL
26618c2ecf20Sopenharmony_ci#define RX_COMP4_PKT_LEN_SHIFT            16
26628c2ecf20Sopenharmony_ci#define RX_COMP4_PERFECT_MATCH_MASK       0x00000003C0000000ULL
26638c2ecf20Sopenharmony_ci#define RX_COMP4_PERFECT_MATCH_SHIFT      30
26648c2ecf20Sopenharmony_ci#define RX_COMP4_ZERO                     0x0000080000000000ULL
26658c2ecf20Sopenharmony_ci#define RX_COMP4_HASH_VAL_MASK            0x0FFFF00000000000ULL
26668c2ecf20Sopenharmony_ci#define RX_COMP4_HASH_VAL_SHIFT           44
26678c2ecf20Sopenharmony_ci#define RX_COMP4_HASH_PASS                0x1000000000000000ULL
26688c2ecf20Sopenharmony_ci#define RX_COMP4_BAD                      0x4000000000000000ULL
26698c2ecf20Sopenharmony_ci#define RX_COMP4_LEN_MISMATCH             0x8000000000000000ULL
26708c2ecf20Sopenharmony_ci
26718c2ecf20Sopenharmony_ci/* we encode the following: ring/index/release. only 14 bits
26728c2ecf20Sopenharmony_ci * are usable.
26738c2ecf20Sopenharmony_ci * NOTE: the encoding is dependent upon RX_DESC_RING_SIZE and
26748c2ecf20Sopenharmony_ci *       MAX_RX_DESC_RINGS. */
26758c2ecf20Sopenharmony_ci#define RX_INDEX_NUM_MASK                 0x0000000000000FFFULL
26768c2ecf20Sopenharmony_ci#define RX_INDEX_NUM_SHIFT                0
26778c2ecf20Sopenharmony_ci#define RX_INDEX_RING_MASK                0x0000000000001000ULL
26788c2ecf20Sopenharmony_ci#define RX_INDEX_RING_SHIFT               12
26798c2ecf20Sopenharmony_ci#define RX_INDEX_RELEASE                  0x0000000000002000ULL
26808c2ecf20Sopenharmony_ci
26818c2ecf20Sopenharmony_cistruct cas_rx_comp {
26828c2ecf20Sopenharmony_ci	__le64     word1;
26838c2ecf20Sopenharmony_ci	__le64     word2;
26848c2ecf20Sopenharmony_ci	__le64     word3;
26858c2ecf20Sopenharmony_ci	__le64     word4;
26868c2ecf20Sopenharmony_ci};
26878c2ecf20Sopenharmony_ci
26888c2ecf20Sopenharmony_cienum link_state {
26898c2ecf20Sopenharmony_ci	link_down = 0,	/* No link, will retry */
26908c2ecf20Sopenharmony_ci	link_aneg,	/* Autoneg in progress */
26918c2ecf20Sopenharmony_ci	link_force_try,	/* Try Forced link speed */
26928c2ecf20Sopenharmony_ci	link_force_ret,	/* Forced mode worked, retrying autoneg */
26938c2ecf20Sopenharmony_ci	link_force_ok,	/* Stay in forced mode */
26948c2ecf20Sopenharmony_ci	link_up		/* Link is up */
26958c2ecf20Sopenharmony_ci};
26968c2ecf20Sopenharmony_ci
26978c2ecf20Sopenharmony_citypedef struct cas_page {
26988c2ecf20Sopenharmony_ci	struct list_head list;
26998c2ecf20Sopenharmony_ci	struct page *buffer;
27008c2ecf20Sopenharmony_ci	dma_addr_t dma_addr;
27018c2ecf20Sopenharmony_ci	int used;
27028c2ecf20Sopenharmony_ci} cas_page_t;
27038c2ecf20Sopenharmony_ci
27048c2ecf20Sopenharmony_ci
27058c2ecf20Sopenharmony_ci/* some alignment constraints:
27068c2ecf20Sopenharmony_ci * TX DESC, RX DESC, and RX COMP must each be 8K aligned.
27078c2ecf20Sopenharmony_ci * TX COMPWB must be 8-byte aligned.
27088c2ecf20Sopenharmony_ci * to accomplish this, here's what we do:
27098c2ecf20Sopenharmony_ci *
27108c2ecf20Sopenharmony_ci * INIT_BLOCK_RX_COMP  = 64k (already aligned)
27118c2ecf20Sopenharmony_ci * INIT_BLOCK_RX_DESC  = 8k
27128c2ecf20Sopenharmony_ci * INIT_BLOCK_TX       = 8k
27138c2ecf20Sopenharmony_ci * INIT_BLOCK_RX1_DESC = 8k
27148c2ecf20Sopenharmony_ci * TX COMPWB
27158c2ecf20Sopenharmony_ci */
27168c2ecf20Sopenharmony_ci#define INIT_BLOCK_TX           (TX_DESC_RING_SIZE)
27178c2ecf20Sopenharmony_ci#define INIT_BLOCK_RX_DESC      (RX_DESC_RING_SIZE)
27188c2ecf20Sopenharmony_ci#define INIT_BLOCK_RX_COMP      (RX_COMP_RING_SIZE)
27198c2ecf20Sopenharmony_ci
27208c2ecf20Sopenharmony_cistruct cas_init_block {
27218c2ecf20Sopenharmony_ci	struct cas_rx_comp rxcs[N_RX_COMP_RINGS][INIT_BLOCK_RX_COMP];
27228c2ecf20Sopenharmony_ci	struct cas_rx_desc rxds[N_RX_DESC_RINGS][INIT_BLOCK_RX_DESC];
27238c2ecf20Sopenharmony_ci	struct cas_tx_desc txds[N_TX_RINGS][INIT_BLOCK_TX];
27248c2ecf20Sopenharmony_ci	__le64 tx_compwb;
27258c2ecf20Sopenharmony_ci};
27268c2ecf20Sopenharmony_ci
27278c2ecf20Sopenharmony_ci/* tiny buffers to deal with target abort issue. we allocate a bit
27288c2ecf20Sopenharmony_ci * over so that we don't have target abort issues with these buffers
27298c2ecf20Sopenharmony_ci * as well.
27308c2ecf20Sopenharmony_ci */
27318c2ecf20Sopenharmony_ci#define TX_TINY_BUF_LEN    0x100
27328c2ecf20Sopenharmony_ci#define TX_TINY_BUF_BLOCK  ((INIT_BLOCK_TX + 1)*TX_TINY_BUF_LEN)
27338c2ecf20Sopenharmony_ci
27348c2ecf20Sopenharmony_cistruct cas_tiny_count {
27358c2ecf20Sopenharmony_ci	int nbufs;
27368c2ecf20Sopenharmony_ci	int used;
27378c2ecf20Sopenharmony_ci};
27388c2ecf20Sopenharmony_ci
27398c2ecf20Sopenharmony_cistruct cas {
27408c2ecf20Sopenharmony_ci	spinlock_t lock; /* for most bits */
27418c2ecf20Sopenharmony_ci	spinlock_t tx_lock[N_TX_RINGS]; /* tx bits */
27428c2ecf20Sopenharmony_ci	spinlock_t stat_lock[N_TX_RINGS + 1]; /* for stat gathering */
27438c2ecf20Sopenharmony_ci	spinlock_t rx_inuse_lock; /* rx inuse list */
27448c2ecf20Sopenharmony_ci	spinlock_t rx_spare_lock; /* rx spare list */
27458c2ecf20Sopenharmony_ci
27468c2ecf20Sopenharmony_ci	void __iomem *regs;
27478c2ecf20Sopenharmony_ci	int tx_new[N_TX_RINGS], tx_old[N_TX_RINGS];
27488c2ecf20Sopenharmony_ci	int rx_old[N_RX_DESC_RINGS];
27498c2ecf20Sopenharmony_ci	int rx_cur[N_RX_COMP_RINGS], rx_new[N_RX_COMP_RINGS];
27508c2ecf20Sopenharmony_ci	int rx_last[N_RX_DESC_RINGS];
27518c2ecf20Sopenharmony_ci
27528c2ecf20Sopenharmony_ci	struct napi_struct napi;
27538c2ecf20Sopenharmony_ci
27548c2ecf20Sopenharmony_ci	/* Set when chip is actually in operational state
27558c2ecf20Sopenharmony_ci	 * (ie. not power managed) */
27568c2ecf20Sopenharmony_ci	int hw_running;
27578c2ecf20Sopenharmony_ci	int opened;
27588c2ecf20Sopenharmony_ci	struct mutex pm_mutex; /* open/close/suspend/resume */
27598c2ecf20Sopenharmony_ci
27608c2ecf20Sopenharmony_ci	struct cas_init_block *init_block;
27618c2ecf20Sopenharmony_ci	struct cas_tx_desc *init_txds[MAX_TX_RINGS];
27628c2ecf20Sopenharmony_ci	struct cas_rx_desc *init_rxds[MAX_RX_DESC_RINGS];
27638c2ecf20Sopenharmony_ci	struct cas_rx_comp *init_rxcs[MAX_RX_COMP_RINGS];
27648c2ecf20Sopenharmony_ci
27658c2ecf20Sopenharmony_ci	/* we use sk_buffs for tx and pages for rx. the rx skbuffs
27668c2ecf20Sopenharmony_ci	 * are there for flow re-assembly. */
27678c2ecf20Sopenharmony_ci	struct sk_buff      *tx_skbs[N_TX_RINGS][TX_DESC_RING_SIZE];
27688c2ecf20Sopenharmony_ci	struct sk_buff_head  rx_flows[N_RX_FLOWS];
27698c2ecf20Sopenharmony_ci	cas_page_t          *rx_pages[N_RX_DESC_RINGS][RX_DESC_RING_SIZE];
27708c2ecf20Sopenharmony_ci	struct list_head     rx_spare_list, rx_inuse_list;
27718c2ecf20Sopenharmony_ci	int                  rx_spares_needed;
27728c2ecf20Sopenharmony_ci
27738c2ecf20Sopenharmony_ci	/* for small packets when copying would be quicker than
27748c2ecf20Sopenharmony_ci	   mapping */
27758c2ecf20Sopenharmony_ci	struct cas_tiny_count tx_tiny_use[N_TX_RINGS][TX_DESC_RING_SIZE];
27768c2ecf20Sopenharmony_ci	u8 *tx_tiny_bufs[N_TX_RINGS];
27778c2ecf20Sopenharmony_ci
27788c2ecf20Sopenharmony_ci	u32			msg_enable;
27798c2ecf20Sopenharmony_ci
27808c2ecf20Sopenharmony_ci	/* N_TX_RINGS must be >= N_RX_DESC_RINGS */
27818c2ecf20Sopenharmony_ci	struct net_device_stats net_stats[N_TX_RINGS + 1];
27828c2ecf20Sopenharmony_ci
27838c2ecf20Sopenharmony_ci	u32			pci_cfg[64 >> 2];
27848c2ecf20Sopenharmony_ci	u8                      pci_revision;
27858c2ecf20Sopenharmony_ci
27868c2ecf20Sopenharmony_ci	int                     phy_type;
27878c2ecf20Sopenharmony_ci	int			phy_addr;
27888c2ecf20Sopenharmony_ci	u32                     phy_id;
27898c2ecf20Sopenharmony_ci#define CAS_FLAG_1000MB_CAP     0x00000001
27908c2ecf20Sopenharmony_ci#define CAS_FLAG_REG_PLUS       0x00000002
27918c2ecf20Sopenharmony_ci#define CAS_FLAG_TARGET_ABORT   0x00000004
27928c2ecf20Sopenharmony_ci#define CAS_FLAG_SATURN         0x00000008
27938c2ecf20Sopenharmony_ci#define CAS_FLAG_RXD_POST_MASK  0x000000F0
27948c2ecf20Sopenharmony_ci#define CAS_FLAG_RXD_POST_SHIFT 4
27958c2ecf20Sopenharmony_ci#define CAS_FLAG_RXD_POST(x)    ((1 << (CAS_FLAG_RXD_POST_SHIFT + (x))) & \
27968c2ecf20Sopenharmony_ci                                 CAS_FLAG_RXD_POST_MASK)
27978c2ecf20Sopenharmony_ci#define CAS_FLAG_ENTROPY_DEV    0x00000100
27988c2ecf20Sopenharmony_ci#define CAS_FLAG_NO_HW_CSUM     0x00000200
27998c2ecf20Sopenharmony_ci	u32                     cas_flags;
28008c2ecf20Sopenharmony_ci	int                     packet_min; /* minimum packet size */
28018c2ecf20Sopenharmony_ci	int			tx_fifo_size;
28028c2ecf20Sopenharmony_ci	int			rx_fifo_size;
28038c2ecf20Sopenharmony_ci	int			rx_pause_off;
28048c2ecf20Sopenharmony_ci	int			rx_pause_on;
28058c2ecf20Sopenharmony_ci	int                     crc_size;      /* 4 if half-duplex */
28068c2ecf20Sopenharmony_ci
28078c2ecf20Sopenharmony_ci	int                     pci_irq_INTC;
28088c2ecf20Sopenharmony_ci	int                     min_frame_size; /* for tx fifo workaround */
28098c2ecf20Sopenharmony_ci
28108c2ecf20Sopenharmony_ci	/* page size allocation */
28118c2ecf20Sopenharmony_ci	int                     page_size;
28128c2ecf20Sopenharmony_ci	int                     page_order;
28138c2ecf20Sopenharmony_ci	int                     mtu_stride;
28148c2ecf20Sopenharmony_ci
28158c2ecf20Sopenharmony_ci	u32			mac_rx_cfg;
28168c2ecf20Sopenharmony_ci
28178c2ecf20Sopenharmony_ci	/* Autoneg & PHY control */
28188c2ecf20Sopenharmony_ci	int			link_cntl;
28198c2ecf20Sopenharmony_ci	int			link_fcntl;
28208c2ecf20Sopenharmony_ci	enum link_state		lstate;
28218c2ecf20Sopenharmony_ci	struct timer_list	link_timer;
28228c2ecf20Sopenharmony_ci	int			timer_ticks;
28238c2ecf20Sopenharmony_ci	struct work_struct	reset_task;
28248c2ecf20Sopenharmony_ci#if 0
28258c2ecf20Sopenharmony_ci	atomic_t		reset_task_pending;
28268c2ecf20Sopenharmony_ci#else
28278c2ecf20Sopenharmony_ci	atomic_t		reset_task_pending;
28288c2ecf20Sopenharmony_ci	atomic_t		reset_task_pending_mtu;
28298c2ecf20Sopenharmony_ci	atomic_t		reset_task_pending_spare;
28308c2ecf20Sopenharmony_ci	atomic_t		reset_task_pending_all;
28318c2ecf20Sopenharmony_ci#endif
28328c2ecf20Sopenharmony_ci
28338c2ecf20Sopenharmony_ci	/* Link-down problem workaround */
28348c2ecf20Sopenharmony_ci#define LINK_TRANSITION_UNKNOWN 	0
28358c2ecf20Sopenharmony_ci#define LINK_TRANSITION_ON_FAILURE 	1
28368c2ecf20Sopenharmony_ci#define LINK_TRANSITION_STILL_FAILED 	2
28378c2ecf20Sopenharmony_ci#define LINK_TRANSITION_LINK_UP 	3
28388c2ecf20Sopenharmony_ci#define LINK_TRANSITION_LINK_CONFIG	4
28398c2ecf20Sopenharmony_ci#define LINK_TRANSITION_LINK_DOWN	5
28408c2ecf20Sopenharmony_ci#define LINK_TRANSITION_REQUESTED_RESET	6
28418c2ecf20Sopenharmony_ci	int			link_transition;
28428c2ecf20Sopenharmony_ci	int 			link_transition_jiffies_valid;
28438c2ecf20Sopenharmony_ci	unsigned long		link_transition_jiffies;
28448c2ecf20Sopenharmony_ci
28458c2ecf20Sopenharmony_ci	/* Tuning */
28468c2ecf20Sopenharmony_ci	u8 orig_cacheline_size;	/* value when loaded */
28478c2ecf20Sopenharmony_ci#define CAS_PREF_CACHELINE_SIZE	 0x20	/* Minimum desired */
28488c2ecf20Sopenharmony_ci
28498c2ecf20Sopenharmony_ci	/* Diagnostic counters and state. */
28508c2ecf20Sopenharmony_ci	int 			casreg_len; /* reg-space size for dumping */
28518c2ecf20Sopenharmony_ci	u64			pause_entered;
28528c2ecf20Sopenharmony_ci	u16			pause_last_time_recvd;
28538c2ecf20Sopenharmony_ci
28548c2ecf20Sopenharmony_ci	dma_addr_t block_dvma, tx_tiny_dvma[N_TX_RINGS];
28558c2ecf20Sopenharmony_ci	struct pci_dev *pdev;
28568c2ecf20Sopenharmony_ci	struct net_device *dev;
28578c2ecf20Sopenharmony_ci#if defined(CONFIG_OF)
28588c2ecf20Sopenharmony_ci	struct device_node	*of_node;
28598c2ecf20Sopenharmony_ci#endif
28608c2ecf20Sopenharmony_ci
28618c2ecf20Sopenharmony_ci	/* Firmware Info */
28628c2ecf20Sopenharmony_ci	u16			fw_load_addr;
28638c2ecf20Sopenharmony_ci	u32			fw_size;
28648c2ecf20Sopenharmony_ci	u8			*fw_data;
28658c2ecf20Sopenharmony_ci};
28668c2ecf20Sopenharmony_ci
28678c2ecf20Sopenharmony_ci#define TX_DESC_NEXT(r, x)  (((x) + 1) & (TX_DESC_RINGN_SIZE(r) - 1))
28688c2ecf20Sopenharmony_ci#define RX_DESC_ENTRY(r, x) ((x) & (RX_DESC_RINGN_SIZE(r) - 1))
28698c2ecf20Sopenharmony_ci#define RX_COMP_ENTRY(r, x) ((x) & (RX_COMP_RINGN_SIZE(r) - 1))
28708c2ecf20Sopenharmony_ci
28718c2ecf20Sopenharmony_ci#define TX_BUFF_COUNT(r, x, y)    ((x) <= (y) ? ((y) - (x)) : \
28728c2ecf20Sopenharmony_ci        (TX_DESC_RINGN_SIZE(r) - (x) + (y)))
28738c2ecf20Sopenharmony_ci
28748c2ecf20Sopenharmony_ci#define TX_BUFFS_AVAIL(cp, i)	((cp)->tx_old[(i)] <= (cp)->tx_new[(i)] ? \
28758c2ecf20Sopenharmony_ci        (cp)->tx_old[(i)] + (TX_DESC_RINGN_SIZE(i) - 1) - (cp)->tx_new[(i)] : \
28768c2ecf20Sopenharmony_ci        (cp)->tx_old[(i)] - (cp)->tx_new[(i)] - 1)
28778c2ecf20Sopenharmony_ci
28788c2ecf20Sopenharmony_ci#define CAS_ALIGN(addr, align) \
28798c2ecf20Sopenharmony_ci     (((unsigned long) (addr) + ((align) - 1UL)) & ~((align) - 1))
28808c2ecf20Sopenharmony_ci
28818c2ecf20Sopenharmony_ci#define RX_FIFO_SIZE                  16384
28828c2ecf20Sopenharmony_ci#define EXPANSION_ROM_SIZE            65536
28838c2ecf20Sopenharmony_ci
28848c2ecf20Sopenharmony_ci#define CAS_MC_EXACT_MATCH_SIZE       15
28858c2ecf20Sopenharmony_ci#define CAS_MC_HASH_SIZE              256
28868c2ecf20Sopenharmony_ci#define CAS_MC_HASH_MAX              (CAS_MC_EXACT_MATCH_SIZE + \
28878c2ecf20Sopenharmony_ci                                      CAS_MC_HASH_SIZE)
28888c2ecf20Sopenharmony_ci
28898c2ecf20Sopenharmony_ci#define TX_TARGET_ABORT_LEN           0x20
28908c2ecf20Sopenharmony_ci#define RX_SWIVEL_OFF_VAL             0x2
28918c2ecf20Sopenharmony_ci#define RX_AE_FREEN_VAL(x)            (RX_DESC_RINGN_SIZE(x) >> 1)
28928c2ecf20Sopenharmony_ci#define RX_AE_COMP_VAL                (RX_COMP_RING_SIZE >> 1)
28938c2ecf20Sopenharmony_ci#define RX_BLANK_INTR_PKT_VAL         0x05
28948c2ecf20Sopenharmony_ci#define RX_BLANK_INTR_TIME_VAL        0x0F
28958c2ecf20Sopenharmony_ci#define HP_TCP_THRESH_VAL             1530 /* reduce to enable reassembly */
28968c2ecf20Sopenharmony_ci
28978c2ecf20Sopenharmony_ci#define RX_SPARE_COUNT                (RX_DESC_RING_SIZE >> 1)
28988c2ecf20Sopenharmony_ci#define RX_SPARE_RECOVER_VAL          (RX_SPARE_COUNT >> 2)
28998c2ecf20Sopenharmony_ci
29008c2ecf20Sopenharmony_ci#endif /* _CASSINI_H */
2901