162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Faraday FTMAC100 10/100 Ethernet 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * (C) Copyright 2009-2011 Faraday Technology 662306a36Sopenharmony_ci * Po-Yu Chuang <ratbert@faraday-tech.com> 762306a36Sopenharmony_ci */ 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci#ifndef __FTMAC100_H 1062306a36Sopenharmony_ci#define __FTMAC100_H 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ci#define FTMAC100_OFFSET_ISR 0x00 1362306a36Sopenharmony_ci#define FTMAC100_OFFSET_IMR 0x04 1462306a36Sopenharmony_ci#define FTMAC100_OFFSET_MAC_MADR 0x08 1562306a36Sopenharmony_ci#define FTMAC100_OFFSET_MAC_LADR 0x0c 1662306a36Sopenharmony_ci#define FTMAC100_OFFSET_MAHT0 0x10 1762306a36Sopenharmony_ci#define FTMAC100_OFFSET_MAHT1 0x14 1862306a36Sopenharmony_ci#define FTMAC100_OFFSET_TXPD 0x18 1962306a36Sopenharmony_ci#define FTMAC100_OFFSET_RXPD 0x1c 2062306a36Sopenharmony_ci#define FTMAC100_OFFSET_TXR_BADR 0x20 2162306a36Sopenharmony_ci#define FTMAC100_OFFSET_RXR_BADR 0x24 2262306a36Sopenharmony_ci#define FTMAC100_OFFSET_ITC 0x28 2362306a36Sopenharmony_ci#define FTMAC100_OFFSET_APTC 0x2c 2462306a36Sopenharmony_ci#define FTMAC100_OFFSET_DBLAC 0x30 2562306a36Sopenharmony_ci#define FTMAC100_OFFSET_MACCR 0x88 2662306a36Sopenharmony_ci#define FTMAC100_OFFSET_MACSR 0x8c 2762306a36Sopenharmony_ci#define FTMAC100_OFFSET_PHYCR 0x90 2862306a36Sopenharmony_ci#define FTMAC100_OFFSET_PHYWDATA 0x94 2962306a36Sopenharmony_ci#define FTMAC100_OFFSET_FCR 0x98 3062306a36Sopenharmony_ci#define FTMAC100_OFFSET_BPR 0x9c 3162306a36Sopenharmony_ci#define FTMAC100_OFFSET_TS 0xc4 3262306a36Sopenharmony_ci#define FTMAC100_OFFSET_DMAFIFOS 0xc8 3362306a36Sopenharmony_ci#define FTMAC100_OFFSET_TM 0xcc 3462306a36Sopenharmony_ci#define FTMAC100_OFFSET_TX_MCOL_SCOL 0xd4 3562306a36Sopenharmony_ci#define FTMAC100_OFFSET_RPF_AEP 0xd8 3662306a36Sopenharmony_ci#define FTMAC100_OFFSET_XM_PG 0xdc 3762306a36Sopenharmony_ci#define FTMAC100_OFFSET_RUNT_TLCC 0xe0 3862306a36Sopenharmony_ci#define FTMAC100_OFFSET_CRCER_FTL 0xe4 3962306a36Sopenharmony_ci#define FTMAC100_OFFSET_RLC_RCC 0xe8 4062306a36Sopenharmony_ci#define FTMAC100_OFFSET_BROC 0xec 4162306a36Sopenharmony_ci#define FTMAC100_OFFSET_MULCA 0xf0 4262306a36Sopenharmony_ci#define FTMAC100_OFFSET_RP 0xf4 4362306a36Sopenharmony_ci#define FTMAC100_OFFSET_XP 0xf8 4462306a36Sopenharmony_ci 4562306a36Sopenharmony_ci/* 4662306a36Sopenharmony_ci * Interrupt status register & interrupt mask register 4762306a36Sopenharmony_ci */ 4862306a36Sopenharmony_ci#define FTMAC100_INT_RPKT_FINISH (1 << 0) 4962306a36Sopenharmony_ci#define FTMAC100_INT_NORXBUF (1 << 1) 5062306a36Sopenharmony_ci#define FTMAC100_INT_XPKT_FINISH (1 << 2) 5162306a36Sopenharmony_ci#define FTMAC100_INT_NOTXBUF (1 << 3) 5262306a36Sopenharmony_ci#define FTMAC100_INT_XPKT_OK (1 << 4) 5362306a36Sopenharmony_ci#define FTMAC100_INT_XPKT_LOST (1 << 5) 5462306a36Sopenharmony_ci#define FTMAC100_INT_RPKT_SAV (1 << 6) 5562306a36Sopenharmony_ci#define FTMAC100_INT_RPKT_LOST (1 << 7) 5662306a36Sopenharmony_ci#define FTMAC100_INT_AHB_ERR (1 << 8) 5762306a36Sopenharmony_ci#define FTMAC100_INT_PHYSTS_CHG (1 << 9) 5862306a36Sopenharmony_ci 5962306a36Sopenharmony_ci/* 6062306a36Sopenharmony_ci * Interrupt timer control register 6162306a36Sopenharmony_ci */ 6262306a36Sopenharmony_ci#define FTMAC100_ITC_RXINT_CNT(x) (((x) & 0xf) << 0) 6362306a36Sopenharmony_ci#define FTMAC100_ITC_RXINT_THR(x) (((x) & 0x7) << 4) 6462306a36Sopenharmony_ci#define FTMAC100_ITC_RXINT_TIME_SEL (1 << 7) 6562306a36Sopenharmony_ci#define FTMAC100_ITC_TXINT_CNT(x) (((x) & 0xf) << 8) 6662306a36Sopenharmony_ci#define FTMAC100_ITC_TXINT_THR(x) (((x) & 0x7) << 12) 6762306a36Sopenharmony_ci#define FTMAC100_ITC_TXINT_TIME_SEL (1 << 15) 6862306a36Sopenharmony_ci 6962306a36Sopenharmony_ci/* 7062306a36Sopenharmony_ci * Automatic polling timer control register 7162306a36Sopenharmony_ci */ 7262306a36Sopenharmony_ci#define FTMAC100_APTC_RXPOLL_CNT(x) (((x) & 0xf) << 0) 7362306a36Sopenharmony_ci#define FTMAC100_APTC_RXPOLL_TIME_SEL (1 << 4) 7462306a36Sopenharmony_ci#define FTMAC100_APTC_TXPOLL_CNT(x) (((x) & 0xf) << 8) 7562306a36Sopenharmony_ci#define FTMAC100_APTC_TXPOLL_TIME_SEL (1 << 12) 7662306a36Sopenharmony_ci 7762306a36Sopenharmony_ci/* 7862306a36Sopenharmony_ci * DMA burst length and arbitration control register 7962306a36Sopenharmony_ci */ 8062306a36Sopenharmony_ci#define FTMAC100_DBLAC_INCR4_EN (1 << 0) 8162306a36Sopenharmony_ci#define FTMAC100_DBLAC_INCR8_EN (1 << 1) 8262306a36Sopenharmony_ci#define FTMAC100_DBLAC_INCR16_EN (1 << 2) 8362306a36Sopenharmony_ci#define FTMAC100_DBLAC_RXFIFO_LTHR(x) (((x) & 0x7) << 3) 8462306a36Sopenharmony_ci#define FTMAC100_DBLAC_RXFIFO_HTHR(x) (((x) & 0x7) << 6) 8562306a36Sopenharmony_ci#define FTMAC100_DBLAC_RX_THR_EN (1 << 9) 8662306a36Sopenharmony_ci 8762306a36Sopenharmony_ci/* 8862306a36Sopenharmony_ci * MAC control register 8962306a36Sopenharmony_ci */ 9062306a36Sopenharmony_ci#define FTMAC100_MACCR_XDMA_EN (1 << 0) 9162306a36Sopenharmony_ci#define FTMAC100_MACCR_RDMA_EN (1 << 1) 9262306a36Sopenharmony_ci#define FTMAC100_MACCR_SW_RST (1 << 2) 9362306a36Sopenharmony_ci#define FTMAC100_MACCR_LOOP_EN (1 << 3) 9462306a36Sopenharmony_ci#define FTMAC100_MACCR_CRC_DIS (1 << 4) 9562306a36Sopenharmony_ci#define FTMAC100_MACCR_XMT_EN (1 << 5) 9662306a36Sopenharmony_ci#define FTMAC100_MACCR_ENRX_IN_HALFTX (1 << 6) 9762306a36Sopenharmony_ci#define FTMAC100_MACCR_RCV_EN (1 << 8) 9862306a36Sopenharmony_ci#define FTMAC100_MACCR_HT_MULTI_EN (1 << 9) 9962306a36Sopenharmony_ci#define FTMAC100_MACCR_RX_RUNT (1 << 10) 10062306a36Sopenharmony_ci#define FTMAC100_MACCR_RX_FTL (1 << 11) 10162306a36Sopenharmony_ci#define FTMAC100_MACCR_RCV_ALL (1 << 12) 10262306a36Sopenharmony_ci#define FTMAC100_MACCR_CRC_APD (1 << 14) 10362306a36Sopenharmony_ci#define FTMAC100_MACCR_FULLDUP (1 << 15) 10462306a36Sopenharmony_ci#define FTMAC100_MACCR_RX_MULTIPKT (1 << 16) 10562306a36Sopenharmony_ci#define FTMAC100_MACCR_RX_BROADPKT (1 << 17) 10662306a36Sopenharmony_ci 10762306a36Sopenharmony_ci/* 10862306a36Sopenharmony_ci * PHY control register 10962306a36Sopenharmony_ci */ 11062306a36Sopenharmony_ci#define FTMAC100_PHYCR_MIIRDATA 0xffff 11162306a36Sopenharmony_ci#define FTMAC100_PHYCR_PHYAD(x) (((x) & 0x1f) << 16) 11262306a36Sopenharmony_ci#define FTMAC100_PHYCR_REGAD(x) (((x) & 0x1f) << 21) 11362306a36Sopenharmony_ci#define FTMAC100_PHYCR_MIIRD (1 << 26) 11462306a36Sopenharmony_ci#define FTMAC100_PHYCR_MIIWR (1 << 27) 11562306a36Sopenharmony_ci 11662306a36Sopenharmony_ci/* 11762306a36Sopenharmony_ci * PHY write data register 11862306a36Sopenharmony_ci */ 11962306a36Sopenharmony_ci#define FTMAC100_PHYWDATA_MIIWDATA(x) ((x) & 0xffff) 12062306a36Sopenharmony_ci 12162306a36Sopenharmony_ci/* 12262306a36Sopenharmony_ci * Transmit descriptor, aligned to 16 bytes 12362306a36Sopenharmony_ci */ 12462306a36Sopenharmony_cistruct ftmac100_txdes { 12562306a36Sopenharmony_ci __le32 txdes0; 12662306a36Sopenharmony_ci __le32 txdes1; 12762306a36Sopenharmony_ci __le32 txdes2; /* TXBUF_BADR */ 12862306a36Sopenharmony_ci unsigned int txdes3; /* not used by HW */ 12962306a36Sopenharmony_ci} __attribute__ ((aligned(16))); 13062306a36Sopenharmony_ci 13162306a36Sopenharmony_ci#define FTMAC100_TXDES0_TXPKT_LATECOL (1 << 0) 13262306a36Sopenharmony_ci#define FTMAC100_TXDES0_TXPKT_EXSCOL (1 << 1) 13362306a36Sopenharmony_ci#define FTMAC100_TXDES0_TXDMA_OWN (1 << 31) 13462306a36Sopenharmony_ci 13562306a36Sopenharmony_ci#define FTMAC100_TXDES1_TXBUF_SIZE(x) ((x) & 0x7ff) 13662306a36Sopenharmony_ci#define FTMAC100_TXDES1_LTS (1 << 27) 13762306a36Sopenharmony_ci#define FTMAC100_TXDES1_FTS (1 << 28) 13862306a36Sopenharmony_ci#define FTMAC100_TXDES1_TX2FIC (1 << 29) 13962306a36Sopenharmony_ci#define FTMAC100_TXDES1_TXIC (1 << 30) 14062306a36Sopenharmony_ci#define FTMAC100_TXDES1_EDOTR (1 << 31) 14162306a36Sopenharmony_ci 14262306a36Sopenharmony_ci/* 14362306a36Sopenharmony_ci * Receive descriptor, aligned to 16 bytes 14462306a36Sopenharmony_ci */ 14562306a36Sopenharmony_cistruct ftmac100_rxdes { 14662306a36Sopenharmony_ci __le32 rxdes0; 14762306a36Sopenharmony_ci __le32 rxdes1; 14862306a36Sopenharmony_ci __le32 rxdes2; /* RXBUF_BADR */ 14962306a36Sopenharmony_ci unsigned int rxdes3; /* not used by HW */ 15062306a36Sopenharmony_ci} __attribute__ ((aligned(16))); 15162306a36Sopenharmony_ci 15262306a36Sopenharmony_ci#define FTMAC100_RXDES0_RFL 0x7ff 15362306a36Sopenharmony_ci#define FTMAC100_RXDES0_MULTICAST (1 << 16) 15462306a36Sopenharmony_ci#define FTMAC100_RXDES0_BROADCAST (1 << 17) 15562306a36Sopenharmony_ci#define FTMAC100_RXDES0_RX_ERR (1 << 18) 15662306a36Sopenharmony_ci#define FTMAC100_RXDES0_CRC_ERR (1 << 19) 15762306a36Sopenharmony_ci#define FTMAC100_RXDES0_FTL (1 << 20) 15862306a36Sopenharmony_ci#define FTMAC100_RXDES0_RUNT (1 << 21) 15962306a36Sopenharmony_ci#define FTMAC100_RXDES0_RX_ODD_NB (1 << 22) 16062306a36Sopenharmony_ci#define FTMAC100_RXDES0_LRS (1 << 28) 16162306a36Sopenharmony_ci#define FTMAC100_RXDES0_FRS (1 << 29) 16262306a36Sopenharmony_ci#define FTMAC100_RXDES0_RXDMA_OWN (1 << 31) 16362306a36Sopenharmony_ci 16462306a36Sopenharmony_ci#define FTMAC100_RXDES1_RXBUF_SIZE(x) ((x) & 0x7ff) 16562306a36Sopenharmony_ci#define FTMAC100_RXDES1_EDORR (1 << 31) 16662306a36Sopenharmony_ci 16762306a36Sopenharmony_ci#endif /* __FTMAC100_H */ 168